I've read How to debug Visual Studio extensions.
As a fact, VS2013 sets up extension project automatically for that.
I have a number of extensions (also add-ons and so on: Resharper, OzCode, GitExtensions..). All of them have slow loading times, obviously.
Is there a way, to run extension debug session on a "clean" Visual Studio? Just vanilla: nothing installed except extension under debug.
EDIT: just wanted to clear a little: resharper is not loading itself in experimental hive, some other extensions are, though
Welcome to the wonderful world of Visual Studio extensibility!
In order to prepare your environment for any serious extension development, you will need to do several things, involving moving installed extensions around and changing Visual Studio configuration files. Below is a brief explanation about the process:
Prerequisites
Before going further, here is the necessary "knowledge" every extension developer needs to posses:
First two articles are fairly old, but they still hold crucial information. In Visual Studio 2012 and above, the VSIX discovery process was changed slightly, so that Visual Studio does not rebuild the package cache on every startup. To rebuild the package cache, run from an elevated Developer Command Prompt for the specific version of Visual Studio:
or use the undocumented command:
which does not require elevation, but rather it tells Visual Studio to refresh its package cache on the next restart.
Most of the time, all extensions you install (e.g. ReSharper, OzCode, other extensions from the Gallery) will by default install themselves per-machine, by placing themselves in
%VSINSTALLDIR%\Common7\IDE\Extensions
. Remember that the defaultpkgdef
search path (as defined bydevenv.pkgdef
) is:This means, whenever you start Visual Studio in any hive, it will first look at the per-machine location for the installed extension, and load them up. Whenever you create a new VSIX project, the default setting is to launch it in the
/RootSuffix Exp
hive, which will still attempt to load the per-machine extensions first.Which brings me to answering your question.
In order to prevent extensions from loading in your other hives, they need to be moved to a per-hive location:
%LOCALAPPDATA%\Microsoft\VisualStudio\<vsVersion><hive>\Extensions
. Later versions of Visual Studio (2013 and above) allow you to do that from the Visual Studio settings, but you need to run Visual Studio as an administrator for this to work:However, instead of running as administrator, it's possible to modify the default package search path, to include the per-user location in it. Then, move the extensions manually to that new location.
Here's what you do:
devenv.pkgdef
, located in the Visual Studio installation directory, e.g.C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.pkgdef
.PkgDefSearchPath
, add$AppDataLocalFolder$\Extensions;
as the first value, before$ApplicationExtensionsFolder$
, so it looks like this:Now you can go to the
Common7\IDE\Extensions
folder, and move the directories of those extensions to the per-user location. So for example, if you wanted to move NCrunch in Visual Studio 2015, take the entire folderRemco Software
, and move it to%LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Extensions
.Finally, refresh Visual Studio package cache, by running one of the two commands above. When you Visual Studio, it will still load the extensions, but whenever you run another hive (Exp or any other), those per-user extensions won't be loaded.
It seems like an involved process, but you only need to do it once, and just for the "huge" extensions (mainly, ReSharper). Note that since v9, ReSharper installs itself per-hive, so you don't even have to do this anymore!
Sorry for the long explanation, hope that helps!