Visual Studio Build Very Slow

Visual StudioPerformanceBuild

Visual Studio Problem Overview


This applies to both 2008 and 2010 versions (and probably earlier ones too). Also to both C++ and C# projects.

An initial build (after reboot) runs at normal speed and with reasonably good CPU utilisation. After "some time" (ie using the computer for "stuff"), a subsequent build might run very, very slowly and with very low CPU utilisation. The only fix I have found seems to be a reboot, then the cycle starts all over again. This happens on both WPF and non-WPF projects, though it's 10 times worse with WPF.

This has happened to me on different machines, even working for different organisations, so I think it's a Visual Studio thing, not an environment thing. I've tried the usual (Google, turn off AV, Intellisense, Resharper etc, and currently looking forward to getting the SSD I have on order).

My current machine spec is 2.7gig quad core, 4GB RAM, XP (haven't got Win7 at work yet), 250Gb hdd etc

Anyone got any ideas what this could be and how to fix it?

Thanks in advance!

Visual Studio Solutions


Solution 1 - Visual Studio

Try this as it worked for me:

Press Windows+R or open run from Start.

Now type %temp% and delete everything from there...

Now open Run again and type prefetch and delete everything from there also.

Now open VS and see the performance.

Solution 2 - Visual Studio

Try this:

Devenv.exe /resetsettings

Solution 3 - Visual Studio

I had the same problem.

I had McAfee security center installed, by disabling the "Real time scan"

Building times did go from 40 seconds for a small project to 1 second.

Solution 4 - Visual Studio

Check your power saving settings in Windows. Set it to "High performance" (even on desktop). This helped for me.

Solution 5 - Visual Studio

Try to use ProcessMonitor (http://technet.microsoft.com/en-us/sysinternals/bb896645) to find what the Visual Studio doing during build process. Add the Filter "ProcessName is devenv.exe then Include" and make some research. It was useful for me.

I have a similar problem - very slow build and debug process - and I can solve it with Process Monitor. I run Process Monitor and saw that Visual Studio process read and write some HTL files many times. It was the Assembly Binding Log (http://msdn.microsoft.com/en-us/library/vstudio/e74a18c4(v=vs.100).aspx) - the utility that store information about libraries binding. Once I enabled this log, and this utility create about 8 Gb HTM logs on my hard drive ) It was very slow. Then i disable logging, the building time of my project decreases from 10 minutes to 10 seconds!

Solution 6 - Visual Studio

am using VS2015 on Windows 10 and had the same issue. I cleared the %temp% and prefetch directories that didn't work.Then I changed the power saving settings from Balanced to High performance and it worked.

Solution 7 - Visual Studio

I did not see this type of answer, so I am thinking that mine, might be helpful to someone. My issue with VS build time was a dumb one: I had the source code on another computer. Each time I tried to build it, a connection has to be made to that computer, which results in VS freeze time for a long time. I discovered this issue, after trying most of the solutions here and elsewhere. (emoticon with banging my head against the desk)

Solution 8 - Visual Studio

I had the same issue. Deleting the hidden .vs folder in the solution directory solved the problem.

Solution 9 - Visual Studio

My fix for very sluggish Visual Studio (building anything took about 1.5-2 min) was to turn off the wireless network.

I had enabled the Wireless Network in addition to the wired one. It seems like my computer tried to use the wireless connection to connect to our local server that is not available to wireless network and that caused the long delay.

Solution 10 - Visual Studio

If there are many project in a single solution, try building the changed one only rather than building the whole solution. Namely, Alt+B+U rather than Alt+B+B.

Solution 11 - Visual Studio

If it's an ASP.NET MVC project, check the .csproj to see if <MvcBuildViews>true</MvcBuildViews> is set. This can cause slow builds.

Solution 12 - Visual Studio

One of the reasons, is Visual Studio keeps rebuilding the same dependent project(s) over and over although nothing has changed. Imagine a Solution having tons of Projects that keep being built for no apparent reason. This wastes HUGE time...

The main solution to this is to revise each "Copy to Output Directory" where it's set to "Always". Change that to "Copy if newer".

It might help to see detailed build log. Open Tools > Options > "Projects and Solutions" > "Build and Run". Now set "MSBuild project build output verbosity" to "Diagnostic"

For more info, this thread discusses this specific point

Solution 13 - Visual Studio

Go to Tools > Options > "Projects and Solutions" > "Build and Run". Now set "MSBuild project build output verbosity" to "Normal" or "Minimal" and same for the other setting "MSBuild project build log file verbosity".

I earlier set it to "Diagnostics" which resulted in long build time duration.

Solution 14 - Visual Studio

About how long is "Some time"? (eg, Hours? Days?)

It could be as simple as you've run out of RAM.. Ctrl-Shift-Esc will load the Process Monitor where you can see your memory utilization, and kill hogs. Once it's run low, your linkers will slow down trying to swap memory to disk (and Windows doesn't typically report swap overhead unless you turn on System utilization). Depending on the size of your project, Linking can use HUGE amounts of memory making tables.

Solution 15 - Visual Studio

At some point I had a programme which took considerably more time to compile after a few weeks. Out of frustration I deleted the debug folder of the solution and projects. What visual studio did was first rebuild the entire solution (which does take some time) but after that, the building process had its old speed back. Not sure if it will work for you as well.

Solution 16 - Visual Studio

Take a Backup of Files and Delete everything in the folder in this folder.

> C:\Users\{username}\AppData\Local\Microsoft\WebsiteCache

Restart Visual Studio and Check the performance.

Hope this helps! Thanks

Solution 17 - Visual Studio

check your Internet Properties option (connections) and make sure Automatically detect settings is checked.

Solution 18 - Visual Studio

As a quick check, run a scan to make sure you don’t have anything currently infecting your system, and then go to Windows Defender Security Center-> Virus & threat Protection -> Disable Real-time protection:

real-time-protection

Rebuild your solution in Visual Studio, noting the total time it takes and observing in Task Manager to see if the Antimalware Service Executable appears to be consuming significant processor time. Assuming your build is faster and your CPU less busy, congratulations, you’ve identified one cause of your performance problems. The next step is to responsibly tell Windows Defender to leave Visual Studio alone without turning it off completely.

Solution 19 - Visual Studio

In my case, I used "wwwroot" directory inside the project directory to store couple GB of data. Moving the "wwwroot" outside the solution directory solved my build times. For my .NET Core web app, I edited launchSettings.json and added new environment variable ASPNETCORE_WEBROOT:

...
"profiles": {
    "Development": {
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_WEBROOT": "../../wwwroot"
      },
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    },
...

Solution 20 - Visual Studio

Since I came here via a Google search, I'll post what I found as the solution for my specific issue.

I had upgraded from .NET Core 1.1 to .NET Core 2.1. This caused the RazorGenerate and RazorTagHelper calls to take 20 seconds each. According to Daniel Crabtree, this was caused by a change in .NET Core 2.1 which enables pre-compiling of Razor views by default.

The fix is to add the following to your .csproj:

<PropertyGroup>
  <UseRazorBuildServer>false</UseRazorBuildServer>
</PropertyGroup>

Source: https://www.danielcrabtree.com/blog/444/speed-up-compilation-of-asp-net-core-2-1-projects

Solution 21 - Visual Studio

In YourProject.csproj, add the target tag in the last line of your project tag

<Project>
.
.
<Target Name="PlatformVerificationTask" Condition="'$(SkipPlatformVerification)' 
    != 'true'" />  
</Project>

Solution 22 - Visual Studio

I've updated all the NuGet packages and it worked!

Solution 23 - Visual Studio

Same issue with any command or function that I was running on VS. After antivirus REAL TIME PROTECTION disabling, the running time was reduced from 10 second to 0.5 or even less seconds. By the way, interesting thing was that antivirus's actions were slowing down the C# running time, but the C++ was totally fine.

Solution 24 - Visual Studio

Move Your Project from SATA to SSD. Install Visual studio in SSD

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMazView Question on Stackoverflow
Solution 1 - Visual StudioSamView Answer on Stackoverflow
Solution 2 - Visual StudiojurgetView Answer on Stackoverflow
Solution 3 - Visual StudioHarm van der HaasView Answer on Stackoverflow
Solution 4 - Visual StudioGijs MaterView Answer on Stackoverflow
Solution 5 - Visual StudioKosixView Answer on Stackoverflow
Solution 6 - Visual Studiodhina sView Answer on Stackoverflow
Solution 7 - Visual StudioGabriel Marius PopescuView Answer on Stackoverflow
Solution 8 - Visual StudioGyörgy KőszegView Answer on Stackoverflow
Solution 9 - Visual StudioAnttiView Answer on Stackoverflow
Solution 10 - Visual StudiochenyView Answer on Stackoverflow
Solution 11 - Visual StudiobkaidView Answer on Stackoverflow
Solution 12 - Visual StudioKorayemView Answer on Stackoverflow
Solution 13 - Visual StudioVikramView Answer on Stackoverflow
Solution 14 - Visual StudioYerazeView Answer on Stackoverflow
Solution 15 - Visual StudioJMRCView Answer on Stackoverflow
Solution 16 - Visual StudioMohamed AlikhanView Answer on Stackoverflow
Solution 17 - Visual StudioewwinkView Answer on Stackoverflow
Solution 18 - Visual Studiokasturi sameerView Answer on Stackoverflow
Solution 19 - Visual StudioxhafanView Answer on Stackoverflow
Solution 20 - Visual StudioTravis DailyView Answer on Stackoverflow
Solution 21 - Visual StudioKhant Htet NaingView Answer on Stackoverflow
Solution 22 - Visual StudioDaniel LoboView Answer on Stackoverflow
Solution 23 - Visual StudioBear GryllsView Answer on Stackoverflow
Solution 24 - Visual Studioraj sansView Answer on Stackoverflow