Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Long wait before Starting to build

Tags:

We have a moderately sized solution, with about 20 projects. In one of them I have my business entities. On compiling any project, visual studio waits and hangs about one and a half minutes on this BusinessEntities project.

I tried our solution in SharpDevelop and it compiles our complete solution, in 18 seconds. Similar timing with MSBuild.

My guess is that VS is trying to find out if the project needs a compile, but this process is about 15 times slower than actually performing the compile!!

I can't switch to the great sharpdevelop, it lacks some small, but essential requirements for our debugging scenarios.

Can I prevent VS from checking this project, And have it compile the projects without such a check, just like sharpdevelop?

I already know about unchecking projects in configuration management to prevent building some projects, but my developers will forget they need to compile this project after updating to latest sources and they face problems that seem strange to them.

Edit: Interesting results of an investigation: The delay happens to one of the projects only. In configuration manager I unchecked all projects, then compiled each of them individually. All projects compile in a few seconds!! The point is this: if that special project is built directly, compiles in a few seconds, if it is being built (or skipped, because it is up-to-date) as a result of building another project that depends on it, VS hangs for about a minute and half, and then decides to compile it (or skip it). My conclusion: Visual studio is checking to know if any files are changed, but for some reasons, for this special project it is extremely inefficient!!

like image 423
Alireza Avatar asked Aug 23 '12 07:08

Alireza


2 Answers

I'd go to Tools -> Options -> Projects and Solutions -> Build and Run and then change the "MSBuild project build [output|build log] verbosity" to Diagnostic. At that level it will include timings which should help you track down the issue.

like image 84
Kaleb Pederson Avatar answered Nov 03 '22 08:11

Kaleb Pederson


We had the same problem with an ASP.NET MVC web project running in Visual Studio 2013. We build the project and nothing happens for about a minute or so and then the output window shows that we are compiling.

Here's what fixed it... open the .csproj file in a text editor and set MvcBuildViews to false:

<MvcBuildViews>false</MvcBuildViews> 

I had to use sysinternals process monitor to figure this out but it's clearly the cause for my situation. The site compiles in less than 5 seconds now and previously took over a minute. During that minute the Asp.net compilation process was putting files and directories into the Temporary Asp.net Files folder.

Warning: If you set this, you'll no longer precompile your views so you will lose the ability to see syntax errors in your views at build time.

like image 43
AaronK Avatar answered Nov 03 '22 09:11

AaronK