VSProjectEvents2::BuildManagerEvents Property
Gets a BuildManagerEvents object that provides access to the BuildManager events.
Assembly: VSLangProj80 (in VSLangProj80.dll)
Implements
VSProjectEvents::BuildManagerEventsThe BuildManagerEvents events are used to track changes made to project items that are associated with custom tools. The DesignTimeOutputDirty event indicates a project item has been added or changed. The DesignTimeOutputDeleted event indicates a project item has been deleted. For more information, see the BuildManager.
This example connects event-handling methods to the DesignTimeOutputDeleted and DesignTimeOutputDirty events for a specific project by using the Events object. For more information about how to run macro samples, see How to: Compile and Run the Automation Object Model Code Examples.
Open a Visual Basic or Visual C# project before running these macros.
' Macro Editor ' Connects events in a Visual Basic or Visual C# project. Imports VSLangProj Imports VSLangProj80 Sub ConnectEvents() Dim proj As Project = DTE.Solution.Projects.Item(1) Dim vsproj As VSProject2 = CType(proj.Object, VSProject2) Dim buildman As BuildManagerEvents = vsproj.Events.BuildManagerEvents AddHandler buildman.DesignTimeOutputDeleted, AddressOf OutputDeleted AddHandler buildman.DesignTimeOutputDirty, AddressOf OutputDirty End Sub Sub OutputDeleted(ByVal moniker As String) MsgBox("Output " & moniker & " was deleted.") End Sub Sub OutputDirty(ByVal moniker As String) MsgBox("Output " & moniker & " is dirty.") End Sub
The next two examples use the late-bound VBBuildManagerEvents property to connect to Visual Basic project events. Use the CSharpBuildManagerEvents property to connect to Visual C# events. For more information about the specific event objects, see Event Objects (Specific to Types of Projects).
There are also two late-bound methods for handling BuildManager object events. The first method allows you to handle events for a particular project and requires the Option Strict Off statement to compile. The parameter to VBImportsEvents is optional. If it is omitted, events for all the Visual Basic projects in the solution are received. This method returns an error if the parameter to the VBBuildManagerEvents call is not of type Project. For more information on the specific event objects, see Event Objects (Specific to Types of Projects).
' Macro editor Option Strict Off Imports VSLangProj Dim WithEvents buildEvents As BuildManagerEvents Sub ConnectProjectBuildManagerEvents() Dim proj As Project = DTE.Solution.Projects.Item(1) buildEvents = DTE.Events.VBBuildManagerEvents(proj) End Sub Public Sub buildEvents_DesignTimeOutputDeleted(ByVal bstrOutputMoniker _ As String) Handles buildEvents.DesignTimeOutputDeleted MsgBox(bstrOutputMoniker) End Sub
The second late-bound method allows you to respond to events for all the projects in the solution. This method does not offer a way to filter events for only a particular project. It will compile with Option Strict On.
' Macro editor Imports VSLangProj Dim WithEvents buildEvents As VSLangProj.BuildManagerEvents Sub ConnectAllBuildManagerEvents() buildEvents = CType(DTE.Events.GetObject("VBBuildManagerEvents"), _ BuildManagerEvents) End Sub Public Sub buildEvents_DesignTimeOutputDeleted(ByVal bstrOutputMoniker _ As String) Handles buildEvents.DesignTimeOutputDeleted MsgBox(bstrOutputMoniker) End Sub