High CPU usage in Visual Studio 2017 Solution

Recently I had an annoying issue with one of my Visual Studio 2017 Solutions, which would run constantly at a very high CPU ~70%, on a quad core, even when idle. Running a build or getting Visual Studio to do anything would actually reduce the CPU usage. 

After lots of googling I came across this post which suggested the following:

  • Deleting the .suo and .vs hidden directory
  • Disabling the source control plugin in Options -> Source Control
  • Turning off Diagnostic Tools via Tools -> Options -> Debugging -> General -> Uncheck "Enable Diagnostic Tools while debugging"
  • Disable the Developer Analytics Tools addon

Despite trying all of the suggestions I was still getting the problem. One thing I had noticed was that the issue was only present in one solution; all my other projects were working fine so that at least narrowed the problem to the Solution file.

I tried the same solution on different machines with the same result so further confirmation that the issue was with the solution. My solution consisted of about 14 existing projects all of which were under source control, initially with Git then moved to VSTS. Eventually I removed each project one by one and then re-added them all, and bingo, problem solved!

I have no idea what was causing the issue, it was either an incorrect .sln file or Visual Studio simply did not like the order in which the projects were referenced.

I was also experiencing another issue where Saving a file would not work or take a very long time. The file would always display as unsaved in the editor ie. appear with the little asterix in tab Program.cs* for example. Since fixing the high CPU problem the saving issue also now seems to be resolved and possibly caused by the High CPU usage blocking the file save operation.