Afternoon all,
I have a very strange problem. When VS 2012 is open, compile times are very slow. This slow compile time is present when building via VS and/or directly via csc.exe from the command line.
To test: Create a folder with the following items:
A batch file (compile.bat) containing:
echo %time%
csc /target:library class1.cs
echo %time%
and a class1.cs containing:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Class1
{
}
}
Now open a visual studio command prompt. Navigate to the above folder and run the batch command, without VS open. On my machine, this takes approximately 10ms, perfect.
I now open VS 2012, open no solution, do nothing other than open the the application so that devenv is running.
Now repeat the test by running the batch file, compile time is now 10000ms (10 seconds).
I have checked the event viewer for anything that is happening when VS is open but not when it's closed, used procmon and filemon to look for file access and checked to see if VS is enabling any services when it is open, all without success/impact.
I have even tried uninstalling and reinstalling VS, this solved the problem for the first few builds but it then reoccurred. Restarting the machine has no effect. I have no plugins installed in VS.
My colleagues machines do not display this problem and they have the same setup. This is all running on a machine with 16gb ram, 64-bit win 7 and SSD.
Anyone got any clues?
You might have extensions installed that slow Visual Studio down. For help on managing extensions to improve performance, see Change extension settings to improve performance. Similarly, you might have tool windows that slow Visual Studio down.
Visual Studio is designed to start up as quickly and efficiently as possible. However, certain Visual Studio extensions and tool windows can adversely affect startup time when they are loaded. You can control the behavior of slow extensions and tool windows in the Manage Visual Studio Performance dialog box.
Check your CPU Consumption The VS Code wiki recommends checking your CPU consumption to see if a process called "extensionHost" is taking up a lot of processing power. If this is the case, it is likely that an extension is causing your problem.
I've figured this out. I believe it was the result of some malware. I diagnosed the problem with the following steps.
Start:
End:
It appeared that a RegCloseKey to HKLM\SOFTWARE\Wow6432Node\5c28f8fbc6fe942 was causing csc.exe to wait for 5 seconds, twice.
RegKey:
I then decided to rename this entry (added _old to the end), I then recompiled....BINGO, it compiled in less than 30ms!
After studying the entries contained in this key and some googleing it turned out that this reg key was the result of some malware. I used the following guide to remove thte malware and now the problem is completely solved.
http://www.explosiveknowledge.net/main/2012/08/19/browsemngr/
Please be aware that the guide above doesn't contain the correct reg entries, I think the virus must have been tweaked at somepoint, I couldn't find the reg entries mentioned in the guide but simply deleted the ones I'd found.
Please note that the 5c28f8fbc6fe942 part of the reg key seems to be randomly generated. If you have this problem is might be different but the values contain within will still talk about "Browser Manager".
Hope this helps someone!
To understand your query we need to look into the concept of response file.
A response file is a text file that contains a set of compiler commandline switches. When you execute CSC.exe, the compiler opens response files and uses any switches that are specified in them as though the switches were passed to CSC.exe on the command line. You instruct the compiler to use a response file by specifying its name on the command line prepended by an @ sign. For example, you could have a response file called MyProject.rsp that contains the following text:
/out:MyProject.exe /target:winexe
To cause CSC.exe to use these settings, you’d invoke it as follows:
csc.exe @MyProject.rsp CodeFile1.cs CodeFile2.cs
This tells the C# compiler what to name the output file and what kind of target to create. As you can see, response files are very convenient because you don’t have to manually express the desired command-line arguments each time you want to compile your project.
When you install the .NET Framework, it installs a default global CSC.rsp file in the %SystemRoot%\Microsoft.NET\Framework\vX.X.Xdirectory (where X.X.X is the version of the .NET Framework you have installed).
The Visual studio 2012 uses this default response file for compiling the code. Because the global CSC.rsp file references all of the assemblies.Referencing all of these assemblies could slow the compiler down a bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With