如果你还在寻找这个问题的答案,试试这个。
绑定到发布事件并在成功推送时调用您的外部命令。我正在做类似的事情来构建解决方案,然后触发 MSpec 测试运行器(博客文章)。
为此,您需要为 PublishEvents_OnPublishDone 添加一个挂钩。通过转到 EnvironmentEvents 模块并添加以下内容来执行此操作:
<System.contextStaticAttribute()> Public WithEvents PublishEvents As EnvDTE80.PublishEvents
Private Sub PublishEvents_OnPublishDone(ByVal Success As Boolean) Handles PublishEvents.OnPublishDone
'call custom module sub here.
End Sub
如果您只想运行外部命令,有时可以这样做。像这样创建你的宏:
Public runExternalCommandOnComplete As Boolean = False
Sub PublishAndRunExternalCommand()
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("04 - Products\04 - Products.WSS").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Publish")
runExternalCommandOnComplete = True
End Sub
然后在 EnvironmentEvents 中添加:(注意:CustomMacros 是您放置上面代码的模块的名称)
<System.contextStaticAttribute()> Public WithEvents PublishEvents As EnvDTE80.PublishEvents
Private Sub PublishEvents_OnPublishDone(ByVal Success As Boolean) Handles PublishEvents.OnPublishDone
CustomMacros.runExternalCommandOnComplete = False
'Where ExternalCommand1 matches the command you want to run
DTE.ExecuteCommand("Tools.ExternalCommand1")
End Sub
那应该这样做。