How to troubleshoot long builds in Visual Studio? - visual-studio

Is it possible in any way to troubleshoot the build process in Visual Studio? I'd like to see which part of the build specifically takes so much time.

Tools\Options\Project and Solutions\Build and Run\MSBuild output verbosity -> verbose.
In the Output Window, you'll get a time summary at the end, and you can see at which point in the process there is a long pause.

Watch the output window in visual studio during a build or build from the command line directly with MSBuild. You should be able to notice where the build process is spending most of its time.

Related

Visual Studio debugger starts Solution build

I've designed a Visual Studio 2022 solution that contains 6 projects. One produces an executable (.exe) and the others produce dlls that are consumed by the executable. I've noticed that when I try to debug the executable, Visual Studio starts a build for the solution every time I debug. I'm at a loss as to why it builds the solution when nothing has changed in any project. I'm assuming that something in a project is causing the build to occur, but, I don't know what that may be.
Any ideas on how to troubleshoot this?
Update: This solution is built for.Net5. I found this setting in the options under SDK-Style projects that does not appear to work.
Go Tools->Options->Projects and Solutions->Build And Run, set MSBuild output to Detailed, build the project, check the output log.
You can also try resetting all settings.
The post, "Visual Studio not auto-building when I press the debug button" solved my problem. I set the following to force Visual Studio to NOT build each time I started the debugger.

How do I save test results from Test Explorer in Visual Studio 2017?

I have an issue with Visual Studio 2017. I generally run a set of tests locally on my own computer using Test Explorer and using Microsoft's own Unit Testing tools in the Visual Studio library. This can take quite sometime. Problem is, if I close visual studio at any point, the results of these tests are lost forever: the pass, the fail, the output, everything.
I need a way to save the results of my tests in case this happens. I'd love it if VS didn't just wipe my test results like this.
I have to run many tests in different windows, using the command prompt to do this is incredibly laborious.
You can use the command line tool VSTest.Console.exe command-line options and save the output to file using /Logger: option.
It can be found under
(Visual-Studio-Directory)\(Version-Year)\Common7\IDE\Extensions\TestPlatform
Sample:
vstest.console.exe "C:\TestProjectFolder\TestProject.dll" --logger:trx
You can configure trace logging using a test settings file, documented here.

Visual Studio Rebuild Solution hangs

I have a solution that is composed of six assemblies. When I initially load the solution and try to build it, it seems that Visual studio just hangs. It says that it’s building, but I see no updates in the Output window. The CPU jump to 100% usage. The only thing I can do is to Cancel the build or to shut down VS 2012 through Task Manager (which takes forever since I have little use of the system at the time due to the 100% cpu usage).
The only way I have been able to build my solution is to rebuild it. Basically, I delete the .sln file. I then create a new one (by opening the first assembly) and build it. I open the next one…build it. I repeat this process until I have all assemblies built. Only after this am I able to rebuild the solution.
Note, that at some point, not sure when, I will once again not be able to build the solution and I have to go through this process over again.
Any ideas as to what might be causing this?
Here is some more information.
I am running VS 2010, VS 2012 and VS 2013 under a VMWare Virtual Machine. I do not think this matters as it open happens (as far as I can tell) with this one solution. It doesn't matter which version of VS I open it with, it will hang.
Really hoping someone can help me resolve this as it is eating into productivity.
UPDATE-----------------------
It appears that I am able to build this solution on the command line using MSBUILD. However, I still cannot debug the application since VS just hangs.

Overall build progress Visual studio 2010

Is there a way to see the overall build progress in Visual studio?
In my solution there are nearly more than 30 projects. So it takes a long time to build the entire project.
I am looking for a way to see 8/30 In progress or something similar to that?
It still doesn't tell you progress, but it might help to see the Build Output window. If you know the order of the projects it should give you a feel of how far along the build is.
You can also investigate this Build Progress plugin (leverages the Windows 7 progress taskbar: https://github.com/alastairs/buildprogress/ discussed here http://www.codebork.com/coding/2009/11/04/creating-small-visual-studio-2010-add.html
Here is quite nice extension for Visual Studio:
VSBuildStatus:
http://visualstudiogallery.msdn.microsoft.com/2A2293B4-1808-44AA-B030-661F6803D8A1?SRC=VSIDE
Taskbar Build Progress displays total build progress into taskbar without adding any more clutter to VS.

Measuring total solution build time in Visual Studio [duplicate]

This question already has answers here:
Displaying build times in Visual Studio
(14 answers)
Closed 9 years ago.
Does any know if there is any native mechanism to report on the total solution build time in Visual Studio 2008? You can change the build verbosity to report build times per project as discussed here or report total build time from msbuild but I’d like to see this in the IDE across an entire solution containing many projects. Short of creating custom pre and post build events, does anyone know if there’s any native output for total build time? Thanks!
For the sake of completeness, the correct answer is "No, you can't report on total solution build time directly within Visual Studio".
Not native and not not for VS 2008 (currently only for VS 2010), but the VSCommands 2010 extension provides these statistics.
See also: VS 2010: Prevent display of Build Summary in the output window
MSBuild will show the total build time when you run it from the command prompt, e.g:
> msbuild MySolution.sln
...
Time Elapsed 00:00:36.94
There's also an easy way to measure the build time per project in Visual Studio 2010. I'm pretty sure it will work in Visual Studio 2008, too. All you have to do is to go to Tools -> Options -> Projects and Solutions -> Build and Run and set the MSBuild project build output verbosity to "Normal" or "Detailed" (I recommend "Normal", as detailed gives too much information).
I think you could probably hook into the OnBuildBegin and OnBuildDone events
http://visualstudiohacks.com/general/customize-your-project-build-process/
In VC++2008, there is the "Build Timing' option in Tools / Options / Projects and solutions / VC++ Project Settings

Resources