visual-studiovisual-studio-2008build-time

Is there a way to display the build time of an entire solution in Visual Studio?


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.


Solution

  • 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
    
    Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
        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
                owPane.OutputString(message)
                Exit For
            End If
        Next
    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.