Since releasing the VS 2008 Shell (isolated), we have been working on service pack 1 with a number of significant improvements, including a reduced redistributable size. But the most common questions we hear from developers is "How do I go about picking exactly what features and components are included in my isolated Shell based application?"
This is the subject of this post.
When you create an Visual Studio Shell Isolated project, one of the files that gets created for you is called <yourProjectName>.pkgundef.
By default, this file is blank, but you can use this as a reverse registry file. What that means is that any registry keys you put into this file will be removed for you. Of course, this file only works for the registry keys that is owned by your shell based application (i.e. everything under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppEnv\9.0\Apps\<YourShellName+RandomGUID>\).
To give you a concrete example, if I wanted to remove the Class View tool window, I would add this entry in my .pkgundef file:
[$RootKey$\ToolWindows\{C9C0AE26-AA77-11d2-B3F0-0000F87570EE}]
The symbol @ROOTKEY replaces HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppEnv\9.0\Apps\<YourShellName+RandomGUID>\ and you can specify any key under it to be removed.
In the above section, we have talked about how .pkgundef works. But when you are customizing your isolated shell, what are the things you can remove? Here is a list of things you would typically want to remove:
We will discuss each item in its own separate section.
If all the functionality that you don't need is contained inside a VS Package, the cleanest thing to do is to unregister it. Since other things like tool windows, editors, VS Services, menus/commands, etc. that are supplied by that VS package will also be removed when that package is removed, you won't need to remove them separately.
As an example, I can put the following entry in my .pkgundef file to remove the web project system package:
[$RootKey$\Packages\{39c9c826-8ef8-4079-8c95-428f5b1c323f}]
As a result of this, all the related menus/commands, tool windows, editors, VS services, and anything else that's tied to this package will also be removed. If you try the above example to remove the web project system package, you will notice that the command under File > New... > Web Site... will be removed.
So how do I figure what packages can be removed? You can use regedit and enumerate all the packages under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppEnv\9.0\Apps\<YourShellName+RandomGUID>\Packages\. For your convenience, I am including all of them in the table below for you to see.
Feature Area
Raw Package Name
Package GUID
Some caveats about removing packages:
I know this experience is not ideal, and we are working on tooling to make this much easier in the longer term. However, I hope this will still help in the short term.
For tool windows that you'd like to remove without removing the associated package, you can just add the entry in the .pkgundef file. You can see a list of tool windows by enumerating the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppEnv\9.0\Apps\<YourShellName+RandomGUID>\ToolWindows\
Again, for your convenience, I have listed them here for you.
Typically, you won't need to use the .pkgundef file if you want to remove menus and commands. Instead, you would use the <YourProjectName>.vsct file.
If you open this file, you will see that it is a large XML file with lots of things commented out. Here is a snippet of what you will see:
The pattern you will see is that each XML element says No_????Command. If you uncomment the element, the corresponding command or menu will disappear. You can do this quickly inside Visual Studio by highlighting the elements you want to uncomment and use the Ctrl+K, Ctrl+U shortcut.
You can go down this list to pick out the commands/menus that you don't want and uncomment them. For the most part, you should be able to figure out which men/command the XML element corresponds to.
Most of the menus/commands can be removed using the .vsct file. But a small number of them cannot be removed this way. The reason is because this .vsct file only controls the "core" environment commands/menus. For example, if you uncomment every element in the VSCT file and run your isolated shell, you will see that you still have File > New... > Web Site... and Tools > Macros... among several other commands. To remove these, you will need to unregister the web project system package and the macros package respectively.
I hope this post has given you some insight into how to make the isolated shell work for you. Like I said earlier, we will be making this experience easier with tooling over time. Ideally, you wouldn't even need to touch the .pkgundef or the .vsct file. You should be able to do all of that via checking/unchecking components to indicate what you want/don't want. But before we get there, you will need to do some more low-level work to make the shell work for you!
thanks, James