Monday, March 10, 2008

Cancelling Build at First Error

I had close to 100 projects in my solution and it was a pain to build it especially when a compile time error occurs in one of earlier projects. I had to wait till entire solution to be done before seeing the error.

So i really wanted the Visual Studio IDE to do was to break the build process at the first project error. I couldn't get much of help from IDE directly so hence i had to depend on Macros. It turned out pretty straightforward.

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) Then
Dim Win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim ow As OutputWindow = CType(Win.Object, OutputWindow)
Count = Count + 1
ow.OutputWindowPanes.Item("Build").OutputString(String.Format("Project number {0} succeeded {1}", Count, System.Environment.NewLine))
End If

End Sub

As you would have noticed, I have added the code in BuildEvents_OnBuildProjConfigDone event of IDE. I have directed the Macro to write down the Project count if its a success (ok..thats useless bit ....i just wanted to know if there is enough time for me to get a cup of tea)