OnBuildBegin does not fire in Visual Studio Macro until I run it from Macro Explorer

穿精又带淫゛_ 提交于 2019-12-24 10:45:06

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/2345467/onbuildbegin-does-not-fire-in-visual-studio-macro-until-i-run-it-from-macro-expl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!