<p>Our build server is taking too long to build one of our C++ projects. It uses <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2008" rel="nofollow noreferrer">Visual Studio 2008</a>, running <code>devenv.com MyApp.sln /Build</code> -- see <a href="https://learn.microsoft.com/en-us/visualstudio/ide/reference/devenv-command-line-switches?view=vs-2022" rel="nofollow noreferrer">devenv command-line switches</a> (although that's for a newer version of VS). Is there a way to get devenv.com to log the time taken to build each project in the solution, so that I know where to focus my efforts?</p>
<p>Improved hardware is not an option in this case.</p>
<p>I've tried setting the output verbosity (under menu <em>Tools</em> → <em>Options</em> → <em>Projects and Solutions</em> → <em>Build and Run</em> → <em>MSBuild project build output verbosity</em>). This doesn't seem to have any effect in the IDE.</p>
<p>When running MSBuild from the command line (and, for Visual Studio 2008, it needs to be MSBuild v3.5), it displays the total time elapsed at the end, but not in the IDE.</p>
<p>I really wanted a time-taken report for each project in the solution, so that I could figure out where the build process was taking its time.</p>

[{'answer_id': 82140, 'author': 'Dave Moore', 'author_id': 6996, 'author_profile': 'https://Stackoverflow.com/users/6996', 'pm_score': 7, 'selected': False, 'text': '<p>Go to menu <em>Tools</em> → <em>Options</em> → <em>Projects and Solutions</em> → <em>Build and Run</em> → <em>MSBuild project build output verbosity</em>. Set to &quot;Normal&quot; or &quot;Detailed&quot;, and the build time will appear in the output window.</p>\n'}, {'answer_id': 82218, 'author': 'Dave Moore', 'author_id': 6996, 'author_profile': 'https://Stackoverflow.com/users/6996', 'pm_score': 3, 'selected': False, 'text': '<p>Since your question involves using DevEnv from the command line, I would also suggest using <a href="http://en.wikipedia.org/wiki/MSBuild" rel="nofollow noreferrer">MSBuild</a> (which can build .sln files without modification).  </p>\n\n<pre><code>msbuild /fl /flp:Verbosity=diagnostic Your.sln\n</code></pre>\n\n<p><code>msbuild /?</code> will show you other useful options for the filelogger.</p>\n'}, {'answer_id': 132526, 'author': 'JesperE', 'author_id': 13051, 'author_profile': 'https://Stackoverflow.com/users/13051', 'pm_score': 9, 'selected': True, 'text': '<p>Menu <em>Tools</em> → <em>Options</em> → <em>Projects and Solutions</em> → <em>VC++ Project Settings</em> → <em>Build Timing</em> should work.</p>\n'}, {'answer_id': 2590002, 'author': 'MattyT', 'author_id': 7405, 'author_profile': 'https://Stackoverflow.com/users/7405', 'pm_score': 3, 'selected': False, 'text': '<p>If you\'re stuck on VS2005 you could use the <a href="http://code.google.com/p/vs-build-timer/" rel="noreferrer">vs-build-timer plugin</a>.  At the completion of a build it shows the total time taken and a (optional) summary of each of the project durations.</p>\n\n<p>Disclaimer; I wrote it.  And yes, I need to create an installer...one day!</p>\n'}, {'answer_id': 14358229, 'author': 'RaaFFC', 'author_id': 1983582, 'author_profile': 'https://Stackoverflow.com/users/1983582', 'pm_score': 3, 'selected': False, 'text': '<p>Menu <em>Tools</em> → <em>Options</em> → <em>Projects and Solutions</em> → <em>Build and Run</em> →</p>\n<p>Set &quot;MSBuild project build output verbosity&quot; from &quot;Minimal&quot; to &quot;Normal&quot;.</p>\n'}, {'answer_id': 17526392, 'author': 'Oliver', 'author_id': 1529004, 'author_profile': 'https://Stackoverflow.com/users/1529004', 'pm_score': 3, 'selected': False, 'text': '<p>For Visual Studio 2012 you could use the <a href="http://visualstudiogallery.msdn.microsoft.com/b0c87e47-f4ee-4935-9a59-f2c81ce692ab" rel="noreferrer">Build Monitor</a> extension.</p>\n'}, {'answer_id': 25203748, 'author': 'Sebastian', 'author_id': 3111930, 'author_profile': 'https://Stackoverflow.com/users/3111930', 'pm_score': 5, 'selected': False, 'text': '<h2>Visual Studio 2012 - 2019</h2>\n<ul>\n<li><p><strong>For MSBuild Projects (e.g., all .NET projects):</strong>\nClick <em>Tools</em> → <em>Options</em> and then select <em>Projects and Solutions</em> → <em>Build and Run</em>.\nChange <em>MSBuild project build output verbosity</em> to <em>Normal</em>. So it will display Time Elapsed in every Solution Project it builds.\nBut there is unfortunately no <em>Elapsed Time Sum</em> over all projects. You will also see the Build started Timestamp</p>\n</li>\n<li><p><strong>For C/C++ Projects:</strong></p>\n</li>\n</ul>\n<p>Click <em>Tools</em> → <em>Options</em> and then select <em>Projects and Solutions</em> → <em>VC++ Project Settings</em>.</p>\n<p>Change <em>Build Timing</em> to <em>Yes</em>.</p>\n'}, {'answer_id': 29146660, 'author': 'InbetweenWeekends', 'author_id': 902874, 'author_profile': 'https://Stackoverflow.com/users/902874', 'pm_score': 2, 'selected': False, 'text': "<p>I ended up here because I just wanted the date and time included in the build output. Should others be searching for something similar it's as simple as adding <code>echo %date% %time%</code> to the Pre-build and/or Post-build events under project, <em>Properties</em> → <em>Compile</em> → <em>Build Events</em>.</p>\n"}, {'answer_id': 31827370, 'author': 'Blue Clouds', 'author_id': 1501191, 'author_profile': 'https://Stackoverflow.com/users/1501191', 'pm_score': 2, 'selected': False, 'text': '<p>Do a build first and see which project is appearing first in the build output (<kbd>Ctrl</kbd> + <kbd>Home</kbd> in the output window). Right click that project → <em>Project Properties</em> → <em>Compile</em> → <em>Build Events</em> → <em>Pre-build</em>. And <code>echo ###########%date% %time%#############</code>.</p>\n\n<p>So every time you see build results (or during build) do <kbd>Ctrl</kbd> + <kbd>Home</kbd> in the output window. And somewhere in that area the time and date stares at your face!</p>\n\n<p>Oh and you might end up adding these details to many projects as the build order can change :)</p>\n\n<hr>\n\n<p>I found a better solution! ###</p>\n\n<p><em>Tools</em> → <em>Options</em> → <em>Projects &amp; Solutions</em> → <em>Build and Run</em> → <em>MSBuild project build output verbosity</em> = Normal (or above <em>Minimal</em>). This adds the time in the beginning/top of output window. <kbd>Ctrl</kbd> + <kbd>Home</kbd> in the output window should do.</p>\n\n<p>If we want to see how much time each projects take then <em>Projects &amp; Solutions</em> → <em>VC++ Project Settings</em> → <em>Build Timing = yes</em>. It is applicable to all projects; "VC++" is misleading.</p>\n'}, {'answer_id': 34118584, 'author': 'buildops', 'author_id': 5603357, 'author_profile': 'https://Stackoverflow.com/users/5603357', 'pm_score': 3, 'selected': False, 'text': '<p>If you want to visualize your build, you can use <a href="https://en.wikipedia.org/wiki/Incredibuild" rel="nofollow noreferrer">Incredibuild</a>. Incredibuild\'s now available in standalone-mode (not distributed, but for use only on 8 cores on your local machine) for free as part of Visual Studio 2015 Update 1.</p>\n<p><strong>Disclaimer: I work for Incredibuild</strong></p>\n'}, {'answer_id': 37139065, 'author': 'Andreas Haferburg', 'author_id': 872616, 'author_profile': 'https://Stackoverflow.com/users/872616', 'pm_score': 1, 'selected': False, 'text': '<p>If you want to invoke an external program that can track your total build times, you can use the following solution for <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2010" rel="nofollow noreferrer">Visual\xa0Studio\xa02010</a> (and maybe older). The code below uses CTime by Casey Muratori. Of course, you can also use it to simply print the build time.</p>\n<p>Open up the macro explorer, and paste the following before <code>End Module</code>:</p>\n<pre><code>Dim buildStart As Date\n\nPrivate Sub RunCtime(ByVal StartRatherThanEnd As Boolean)\n    Dim Arg As String\n    Dim psi As New System.Diagnostics.ProcessStartInfo(&quot;ctime.exe&quot;)\n    If StartRatherThanEnd Then\n        psi.Arguments = &quot;-begin&quot;\n    Else\n        psi.Arguments = &quot;-end&quot;\n    End If\n    psi.Arguments += &quot; c:\\my\\path\\build.ctm&quot;\n    psi.RedirectStandardOutput = False\n    psi.WindowStyle = ProcessWindowStyle.Hidden\n    psi.UseShellExecute = False\n    psi.CreateNoWindow = True\n    Dim process As System.Diagnostics.Process\n    process = System.Diagnostics.Process.Start(psi)\n    Dim myOutput As System.IO.StreamReader = process.StandardOutput\n    process.WaitForExit(2000)\n    If process.HasExited Then\n        Dim output As String = myOutput.ReadToEnd\n        WriteToBuildWindow(&quot;CTime output: &quot; + output)\n    End If\nEnd Sub\n\nPrivate Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin\n    WriteToBuildWindow(&quot;Build started!&quot;)\n    buildStart = Date.Now\n    RunCtime(True)\nEnd Sub\n\nPrivate Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone\n    Dim buildTime = Date.Now - buildStart\n    WriteToBuildWindow(String.Format(&quot;Total build time: {0} seconds&quot;, buildTime.ToString))\n    RunCtime(False)\nEnd Sub\n\nPrivate Sub WriteToBuildWindow(ByVal message As String)\n    Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)\n    Dim ow As OutputWindow = CType(win.Object, OutputWindow)\n    If (Not message.EndsWith(vbCrLf)) Then\n        message = message + vbCrLf\n    End If\n    ow.OutputWindowPanes.Item(&quot;Build&quot;).OutputString(message)\nEnd Sub\n</code></pre>\n<p>The answer was taken from <a href="https://stackoverflow.com/questions/523220/awesome-visual-studio-macros/2112181#2112181">here</a> and <a href="https://blogs.msdn.microsoft.com/vbfaq/2004/05/30/how-can-i-run-another-application-or-batch-file-from-my-visual-basic-net-code/" rel="nofollow noreferrer">here</a>.</p>\n'}, {'answer_id': 51152492, 'author': 'Wesam', 'author_id': 5723127, 'author_profile': 'https://Stackoverflow.com/users/5723127', 'pm_score': 1, 'selected': False, 'text': '<p>Options -> Projects and Solutions -> VC++ Project Settings -> Build Timing</p>\n\n<p><a href="https://i.stack.imgur.com/t4ZxA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t4ZxA.png" alt="enter image description here"></a></p>\n'}, {'answer_id': 54144991, 'author': 'opetroch', 'author_id': 779446, 'author_profile': 'https://Stackoverflow.com/users/779446', 'pm_score': 5, 'selected': False, 'text': '<p>I have created an extension to measure the build times and present the order of events in a graph: <a href="https://marketplace.visualstudio.com/items?itemName=OdysseasPetrocheilos.VisualStudioBuildTimer" rel="nofollow noreferrer">Visual Studio Build Timer</a>.</p>\n<p><a href="https://i.stack.imgur.com/KC8EI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KC8EI.png" alt="Enter image description here" /></a></p>\n<p>It is available on the Visual\xa0Studio market place and works for <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2015" rel="nofollow noreferrer">Visual\xa0Studio\xa02015</a>, <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2017" rel="nofollow noreferrer">Visual\xa0Studio\xa02017</a> and <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2019" rel="nofollow noreferrer">Visual\xa0Studio\xa02019</a>.</p>\n<p>Apart from showing which projects take longer, the chart displays effective dependencies between them, i.e., projects that need to wait for others, which helps figuring out what dependencies need to break to increase the parallelization of your build.</p>\n'}]
['https://Stackoverflow.com/questions/82128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8446/']