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 开发者_StackOverflow社区clicked on build, to the moment it was done.
Is there anyway to do this ? Running Visual Studio 2008.
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.
Tools->Options->Projects and Solutions->VC++ Project Settings->Build Timing
That's an old question but I thought some may still find it useful.
I have written an extension for VS2015 and VS2017. It displays the start and end time for each project, expressed relative to the start of the overall build. Hence the end time of the last project is the total build time for the solution.
I have posted more about the extension here.
精彩评论