views:

144

answers:

1

I have the following Visual Studio Macro:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports MyMacros.EnvironmentEvents
Imports System.Diagnostics

Public Module Module1

    Private WithEvents buildEvents As EnvDTE.BuildEvents = EnvironmentEvents.BuildEvents

    Public Sub BuildEvents_OnBuildBegin() Handles buildEvents.OnBuildBegin
        Dim projectItem As ProjectItem = DTE.Solution.FindProjectItem("T4MVCVB.tt")
        projectItem.Save()
    End Sub

End Module

I can run it from the Macro explorer, and it works great, and after i have double clicked it from the macro explorer and it has run, the eventhandler is invoked on build.

But if I haven't manually run the macro, the eventhandler is never invoked / event is never fired.

What am i missing here?

A: 

I put the section in directly in the EnvironmentEvents Module outside the autogenerated region, and now it fires every time.

Luhmann