Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 330
levesque Avatar asked Jan 21 '10 18:01

levesque


People also ask

How do I check compile time in Visual Studio?

Go to Tools → Options → Projects and Solutions → Build and Run → MSBuild project build output verbosity - set to "Normal" or "Detailed", and the build time will appear in the output window.

What is build solution in Visual Studio?

Build Solution - compiles code files (dll and exe) that have changed. Rebuild Solution - Deletes all compiled files and Compiles them again regardless of whether or not the code has changed.

What does clean do in Visual Studio?

Choose Clean All to delete any intermediate and output files. With only the project and component files left, new instances of the intermediate and output files can then be built.

How do I run a build in Visual Studio?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.

How do I Check my build time in Visual Studio?

Visual Studio Build Timer. Times the build of your Visual Studio solution and shows how much time is spent building each project. Open the tool window from the top menu View -> Other Windows -> Build Timer. Start building your Visual Studio solution.

How do I build a solution in Visual Studio?

To build, rebuild, or clean an entire solution. In Solution Explorer, choose or open the solution. On the menu bar, choose Build, and then choose one of the following commands: Choose Build or Build Solution to compile only those project files and components that have changed since the most recent build. Note.

How to get the build time in MSBuild?

Go to Tools → Options → Projects and Solutions → Build and Run → MSBuild project build output verbosity - set to "Normal" or "Detailed", and the build time will appear in the output window. Show activity on this post. Click Tools -> Options and then select Projects and Solutions -> Build and Run .

How does build timer work in Visual Studio?

Start building your Visual Studio solution. Build Timer records time spent building each project and creates a timeline presented as a bar chart. The timeline allows you to see: the projects that take longer to build


1 Answers

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.

like image 177
Ryan Lundy Avatar answered Oct 22 '22 06:10

Ryan Lundy