Automatically Cancelling a Failed Build in Visual Studio
Stumbled across this little tip on how to automatically cancel a build in progress after getting an error. You normally have to wait for visual studio to try to finish building all of the remaining projects before getting a chance to fix an the issue and this can take a few minutes if you have a lot of projects in your solution.
Step 1: Open the Visual Studio macros IDE by navigating to Tools –> Macros –> Macros IDE.
Step 2: Double click on “MyMacros” and then on “EnvironmentEvents”. You should now be looking at a VB code editor window.
Step 3: Paste the following code directly before the “End Module” line:
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone If Success = False Then DTE.ExecuteCommand("Build.Cancel") End If End Sub
Step 4: Save and close the Macro Editor window and IDE.
All done!comments powered by Disqus