Reputation: 911
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
What is the the cause of the problem, and how can the problem be fixed?
Upvotes: 91
Views: 147728
Reputation:
Try following options
Upvotes: 0
Reputation: 145
My answer will help to speed up local application Just go to task manager -> details -> Devenv.exe Right cick -> set priority to Realtime.
Check the improved performance.
Upvotes: 0
Reputation: 1627
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.
Upvotes: 2
Reputation: 168
In YourProject.csproj, add the target tag in the last line of your project tag
<Project>
.
.
<Target Name="PlatformVerificationTask" Condition="'$(SkipPlatformVerification)'
!= 'true'" />
</Project>
Upvotes: 0
Reputation: 41
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
Upvotes: 0
Reputation: 2416
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"
},
...
Upvotes: 1
Reputation: 1
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.
Upvotes: -1
Reputation: 31
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.
Upvotes: 0
Reputation: 12507
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
Upvotes: 4
Reputation: 2186
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)
Upvotes: 3
Reputation: 1439
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.
Upvotes: 143
Reputation: 18033
I had the same issue. Deleting the hidden .vs
folder in the solution directory solved the problem.
Upvotes: 3
Reputation: 51
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.
Upvotes: 5
Reputation: 321
Check your power saving settings in Windows. Set it to "High performance" (even on desktop). This helped for me.
Upvotes: 19
Reputation: 1335
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
Upvotes: 1
Reputation: 52083
If it's an ASP.NET MVC project, check the .csproj to see if <MvcBuildViews>true</MvcBuildViews>
is set. This can cause slow builds.
Upvotes: 1
Reputation: 2735
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.
Upvotes: 1
Reputation: 19164
check your Internet Properties option (connections) and make sure Automatically detect settings
is checked.
Upvotes: 0
Reputation: 111
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!
Upvotes: 10
Reputation: 1514
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.
Upvotes: 0
Reputation: 384
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.
Upvotes: 24
Reputation: 101
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.
Upvotes: 1
Reputation: 3289
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.
Upvotes: 0