Take the 2-minute tour ×

I know there is a way to display the build time of each project contained in a solution in visual studio. But what I'm looking for is the total time it took to build an entire solution, from the moment I clicked on build, to the moment it was done.

Is there anyway to do this ? Running Visual Studio 2008.

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

EDIT: Here's a way you can write the build time directly to the build window.

Open the Visual Studio Macro IDE.
Navigate to MyMacros > EnvironmentEvents.
Under MyMacros, add a reference to System.Windows.Forms (for the code below to show a popup window).
Add this code to the EnvironmentEvents module:

Dim buildStart As Date

Private Function IsBuild(ByVal scope As EnvDTE.vsBuildScope, ByVal action As EnvDTE.vsBuildAction) As Boolean
    Return scope = vsBuildScope.vsBuildScopeSolution AndAlso (action = vsBuildAction.vsBuildActionBuild OrElse action = vsBuildAction.vsBuildActionRebuildAll)
End Function

Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
    If (IsBuild(Scope, Action)) Then
        buildStart = Date.Now
    End If
End Sub

    If (IsBuild(Scope, Action)) Then
        Dim buildTime = Date.Now - buildStart
        WriteToBuildWindow(String.Format("Build time: {0}", buildTime.ToString))
    End If
End Sub

Private Sub WriteToBuildWindow(ByVal message As String)
    Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
    Dim ow As OutputWindow = CType(win.Object, OutputWindow)
    For Each owPane As OutputWindowPane In ow.OutputWindowPanes
        If (owPane.Name.Equals("Build")) Then
            Exit For
        End If
End Sub

When you build or rebuild the full solution, at the end, the build/rebuild duration will be printed to the build output window. You can change the conditions in IsBuild to suit your preferences.

share|improve this answer
I've added this code to this question as well: stackoverflow.com/questions/523220/awesome-visual-studio-macros I hope others who have similarly useful macros will add them there too. The Visual Studio Macro editor is very powerful, but I haven't run across a good macro repository anywhere. –  Kyralessa Jan 21 '10 at 19:50
EDIT : Weirdly enough, on one of my computers the build ended event is catched... but doesn't pass the IsBuild test, so just returns. I use Visual Assist X on the computer which cannot detect the event, if that makes any difference.. –  levesque Jan 21 '10 at 20:03
Open the error list in the Macro IDE (View menu > Error List) and see if any errors are listed. The Macro IDE is kind of weird about errors; quite often it won't give you any sign they exist other than the fact that the macros don't work. Most likely you're missing an Imports statement or something. –  Kyralessa Jan 21 '10 at 20:06
Yeah, so after rechecking I modified my comment... the function is run, but it's just my build isn't recognized in the IsBuild function. There is no error in the error list... –  levesque Jan 21 '10 at 20:09
I output the scope and action : Scope : vsBuildScopeSolution, Action : 0. –  levesque Jan 21 '10 at 20:10
show 3 more comments

Tools->Options->Projects and Solutions->VC++ Project Settings->Build Timing

share|improve this answer
This outputs the build time of individual projects. –  levesque Jan 21 '10 at 18:41
Bugger ... Well, you could add them all up by hand ... not THAT hard to do ... –  Goz Jan 21 '10 at 18:50
Yeah, but I'm lazy... there's about 30 projects in my solution... –  levesque Jan 21 '10 at 18:52
add comment

Your Answer


