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
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.
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.
check your Internet Properties option (connections) and make sure Automatically detect settings
is checked.
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.
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
Try this:
Devenv.exe /resetsettings