Scrum tool - Visual Studio plug-in as powerful development tool

Hi to everyone.
 
Not long time ago I had a new project. If not to go into greater details, this project had to integrate into Visual Studio 2005 and 2008 for work as native windows (like Output, Search and so on). Another side of functionality was – my program worked with Web-Services, and user had an opportunity to change address for them.  So I had to save configuration setting to a file and allow user to change it. I decided that would be the best choice to include my form with settings into menu Tools->Options. As a result we had an installation package. After installing it, you plug-in integrates into Visual Studio and you can have all your functionality of app inside of IDE.
 
All of that was agenda. Now I will reproduce all my actions to show you how easy it is to create your own VS plug-in which also can integrate into Options Page. To create a new solution to design VS plug-in you should download and install Visual Studio 2008 SDK. A new type of the project will be available after installation in IDE: Visual Studio Integration Package in Other Project Type-> Extensibiliy tab.
 
First of all you need to create a new solution.
The creation of the new project
Picture 1 – The creation of the new project.
 
On the next page of wizard you should select language which you wish to use and the way of signing your package.
Select language
Picture 2 – Select language.
Then you fill in the form with the information about your company and package. Be attentive, you will use this information soon – when Package Load Key will be generating. But we will talk about this a little bit later.
Fill in the information about your package and company
Picture 3 – Fill in the information about your package and company.
Now, we need to configurate the new project. Go to the properties of the project and then to the Debug page. Set the value of “Start external program” into full path for IDE (include file name).
Also you should set Command line argument to /ranu /rootsuffix Exp. That is enough for now. Let`s go to programming J.
You need to add User Control into your project. This Control will be shown when user opens the tab which you will integrate. So what are you waiting for? Go to project -> Add->User Control. Create Control with a name (for example SettingControl).
After that you can create Component Class. You will need it for interaction with plug-in. I’ll allow myself to give some explanation of the mechanism structure of interaction inside of Plug-in.
Internal structure of the VS Plug-In
Picture 4 – Internal structure of the VS Plug-In.
Your Component Class should seems like the following class:
[Guid(GuidStrings.GuidPageCustom)]
    public partial class SettingPage : DialogPage
    {
        #region Fields
        // The path to the image file which must be shown.
        private string selectedImagePath = String.Empty;
        #endregion Fields
 
        #region Properties
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        protected override IWin32Window Window
        {
            get
            {
                SettingControl page = new SettingControl();
                page.Location = new Point(0, 0);
                return page;
            }
        }
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string CustomBitmap
        {
            get
            {
                return selectedImagePath;
            }
            set
            {
                selectedImagePath = value;
            }
        }
        #endregion Properties
}
As you can see, in override property Window on get we create new instance of our UserControl which you add (in my case it`s SettingControl). And I set GUID to my SettingPage:
 [Guid(GuidStrings.GuidPageCustom)].
 
By the way, for more comfortable future work I created a new static GuidStrings class. I had only one reason to have done this – contain all GUIDs of package and classes. Of course, you can choose any other way for storing and operating with Identifiers.
The next step – to make your application integrated into Option Page of IDE, so write down [ProvideOptionPageAttribute(typeof(SettingPage), "Node Name", "Child Node Name", 101, 107, true)] in Package file(name PackageName+Package.cs).
When I just create a simple solution, my Package file looks like the following (VSPackage5Package.cs):
[PackageRegistration(UseManagedResourcesOnly = true)]
    [InstalledProductRegistration(false, "#110", "#112", "1.0", IconResourceID = 400)]
    [ProvideLoadKey("Standard", "1.0", "Package Name", "Company", 1)]
    [Guid(GuidList.guidVSPackage5PkgString)]
    [ProvideOptionPageAttribute(typeof(SettingPage), "Node Name", "Child Node Name", 101, 107, true)]
    public sealed class VSPackage5Package : Package
    {
        public VSPackage5Package()
        {
        }
        protected override void Initialize()
        {
            base.Initialize();
        }
}
I have skiped all comments and unnecessary code, don`t worry if you don`t have a similar code ;-).
Be attentive, I remove attribute
[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0Exp")] 

in VSPackage5Package class. You can place it for the first time, but in release version, we will create an installation package, so this attribute won’t be useful for us L.

 
Software\\Microsoft\\VisualStudio\\9.0Exp – It`s registry path to VS Experimental hive node.
 
 If you run the application, you can go to the menu Tools->Options and find out node you have created and see your UserControl as main placeholder of the Option page.
So, let`s start the creation of installation package for our plug-in. We need to add Setup Project to the solution.
After that, go to the “File System” view of installation solution. Add into the Application Folder – Project Output -> Primary Output.
This is more challenging part then the other – the generation of the Package Load Key.
Go to VSIP Site register or sign-in as Live ID member. After that go by the link on the bottom of the page “Take Me There”.
You should work with the left part of the page (the generation of the Package Load Key). Fill in all the fields and push the button Generate PLK.  The Key that you have received you should put down in the file VSPackage.resx under unique resource Name (I select 105).
                You should format this key into one line, if you don’t do this – your package won’t be loaded into IDE !!!!
Correct value of the attribute ProvideLoadKey is in the package file. My string looks as:
[ProvideLoadKey("Standard", "1.0", "VSPackage5Package", "CigetSoftware", 105)]
Then, we should generate a registry script for Visual Studio 2005 (the same way for registration for 2008 version of VS).
In command line put down the following command:
<path to Visual Studio SDK>\VisualStudioIntegration\Tools\Bin\RegPkg.exe /root: Software\Microsoft\VisualStudio\<version of VS> /regfile:2005.reg <path to necessary DLL>
In my case command line looks like:
C:\Program Files\Microsoft Visual Studio 2008 SDK\VisualStudioIntegration\Tools\Bin\RegPkg.exe /root:Software\Microsoft\VisualStudio\8.0 /regfile:2005.reg C:\VSPackage5Package.dll.
As the result of generation we have the file 2005.reg, which will be imported into Registry View of the Setup Project. All you need – just set Condition and DeleteAtUninstall properties (as you wish).

Set DeleteAtUninstall property as you need, but BE VERY ATTENTIVE! I recommend you back up the registry before any manipulation with it. You will have a big problem if you have any gaps. J
That is all. Have fun.

Useful links, which help for you to have more deep knowledge in VS Plug-In.
P. S. Don`t hesitate to ask me for any questions. Also, I hope my experience will help you to resolve a lot of problems which I faced when I had been writing my software.