当前位置: 动力学知识库 > 问答 > 编程问答 >

Is there any way to trigger some macro after build in visual studio

问题描述:

I want to count how many times i built on VS.NET .

I have a plan. If i run svn commit when i build to project, i would have build count on revision number :)

I didn't write any macro which can execute a command. And i don't know visual studio is allowing to prebuild event for this kind of request.

网友答案:

You can use pre/post build events.

In your project properties, go to the Build events tab - there is space for both pre build and post build commands.

See this blog post on how incrementing build numbers can be done.

网友答案:

Yes this is possible.

  • Open up the Macros IDE
  • Open the file called environmentEvents

This file has the various DTE event objects declared and you can easily add a handler like so.

Private Sub PostBuild() Handles BuildEvents.OnBuildDone
  ' Your code here
End Sub
网友答案:

Also can use:

Dim WithEvents myTimer As Timers.Timer

Sub CustomBuild()
    DTE.ExecuteCommand("Build.BuildAll")
    myTimer = New Timers.Timer
    myTimer.Interval = 0.05
    myTimer.Start()
End Sub

Sub myTimer_Elapsed(ByVal ee As Object, ByVal dd As Timers.ElapsedEventArgs) Handles myTimer.Elapsed
    If DTE.Solution.SolutionBuild.BuildState <> vsBuildState.vsBuildStateInProgress Then
        myTimer.Stop()
    End If
    If DTE.Solution.SolutionBuild.BuildState <> vsBuildState.vsBuildStateInProgress And DTE.Solution.SolutionBuild.LastBuildInfo <> 1 Then
        ... build was successful ...
    End If
End Sub
分享给朋友:
您可能感兴趣的文章:
随机阅读: