Skip to content

Commit 0389d84

Browse files
jasonmalinowskiKevinRansom
authored andcommitted
Fix build events buttons even more correctly (#3399)
* Correctly fetch the IVsBuildMacroInfo to use for the build events page This code is blindly copied and pasted from https://github.com/dotnet/project-system/blob/88606ba869a29aa24979e0d14a199b2430f31f43/src/Microsoft.VisualStudio.Editors/PropPages/BuildEventsPropPage.vb#L162-L176 I will fully admit I have no idea how this is supposed to work. * Even more correctly fetch the IVsBuildMacroInfo to use for the build events page My previous change broke projects with the old project system. Try the old path and if that doesn't work, then try the new path.
1 parent aa88d31 commit 0389d84

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

vsintegration/src/FSharp.ProjectSystem.PropertyPages/PropertyPages/BuildEventsPropPage.vb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,22 @@ Namespace Microsoft.VisualStudio.Editors.PropertyPages
336336
Dim MacroEval As IVsBuildMacroInfo
337337
Dim MacroValue As String = Nothing
338338

339-
MacroEval = CType(m_Objects(0), IVsBuildMacroInfo)
339+
' The old project system provides IVsBuildMacroInfo this way...
340+
MacroEval = TryCast(m_Objects(0), IVsBuildMacroInfo)
341+
If MacroEval Is Nothing Then
342+
Dim Hier As IVsHierarchy = Nothing
343+
Dim ItemId As UInteger
344+
Dim ThisObj As Object = m_Objects(0)
345+
346+
' ...whereas CPS requires us to go through IVsBrowseObject.
347+
If TypeOf ThisObj Is IVsBrowseObject Then
348+
VSErrorHandler.ThrowOnFailure(CType(ThisObj, IVsBrowseObject).GetProjectItem(Hier, ItemId))
349+
ElseIf TypeOf ThisObj Is IVsCfgBrowseObject Then
350+
VSErrorHandler.ThrowOnFailure(CType(ThisObj, IVsCfgBrowseObject).GetProjectItem(Hier, ItemId))
351+
End If
352+
MacroEval = CType(Hier, IVsBuildMacroInfo)
353+
End If
354+
340355
VSErrorHandler.ThrowOnFailure(MacroEval.GetBuildMacroValue(MacroName, MacroValue))
341356

342357
Return MacroValue

0 commit comments

Comments
 (0)