Udostępnij za pośrednictwem


VSProjectEvents.BuildManagerEvents Property

Gets a BuildManagerEvents object that provides access to the BuildManager events.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

Syntax

'Declaration
ReadOnly Property BuildManagerEvents As BuildManagerEvents
    Get
BuildManagerEvents BuildManagerEvents { get; }
property BuildManagerEvents^ BuildManagerEvents {
    BuildManagerEvents^ get ();
}
abstract BuildManagerEvents : BuildManagerEvents
function get BuildManagerEvents () : BuildManagerEvents

Property Value

Type: VSLangProj.BuildManagerEvents
Returns a BuildManagerEvents object.

Remarks

The BuildManager events are used to track changes made to project items that are associated with custom tools. The DesignTimeOutputDirty indicates a project item has been added or changed. The DesignTimeOutputDeleted indicates a project item has been deleted. For more information, see the BuildManager.

Examples

This example connects event-handling methods to the DesignTimeOutputDeleted and DesignTimeOutputDirty for a specific project using the Events object.

' Macro Editor
' Connects events in a Visual Basic or Visual C# project.
Imports VSLangProj
Sub ConnectEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   Dim vsproj As VSProject = CType(proj.Object, VSProject)
   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.

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.

' 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

.NET Framework Security

See Also

Reference

VSProjectEvents Interface

VSLangProj Namespace