Make WiX setup for a Wizard of Visual Studio

For learns the WiX toolset I have decided to write a setup for install a Wizard of Visual Studio. This setup is very easy with WiX and his Visual Studio extension.

This wxs file make the follow steps:

  1. Install the IWizard implementation in the GAC repository of target system.
  2. Copy the Template for Visual Studio 2005 or 2008 in his ProjectTemplate folder.
  3. Execute the command to install the template in visual studio (devenv /installvstemplates)

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 3      xmlns:vs="http://schemas.microsoft.com/wix/VSExtension">
 4   <Product Id="????????-????-????-????-??????????"
 5            Name="MySDK"
 6            Language="1033"
 7            Version="1.0.0.0"
 8            Manufacturer="Ringo Software"
 9            UpgradeCode="????????-????-????-????-??????????">
10
11     <Package InstallerVersion="200" Compressed="yes" />
12     <Media Id="1" Cabinet="MySDK.cab" EmbedCab="yes" />
13
14     <!-- Installation condition -->
15     <Condition Message="You need to be an administrator to install this tool.">
16       Privileged
17     </Condition>
18     <Condition Message="An old version of product is already installed.">
19       NOT NEWERVERSIONDETECTED
20     </Condition>
21     <Condition Message="This setup requires Visual C# 2005 or 2008 standard or higher.">
22       VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED OR VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED
23     </Condition>
24
25
26     <PropertyRef Id="VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED"/>
27     <PropertyRef Id="VS2005_PROJECTTEMPLATES_DIR"/>
28     <PropertyRef Id="VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED"/>
29     <PropertyRef Id="VS90_PROJECTTEMPLATES_DIR"/>
30
31
32     <Directory Id="TARGETDIR" Name="SourceDir">
33       <Directory Id="VS2005_PROJECTTEMPLATES_DIR">
34         <Directory Id="CSHARP80" Name="CSharp">
35           <Directory Id="PFOLDER80" Name="MySDK">
36             <Component Id="Template2005" Guid="????????-????-????-????-??????????">
37               <File Id="Template2005.zip_ID" Name="Template80.zip" DiskId="1" Source="Template80.zip"/>
38             </Component>
39           </Directory>
40         </Directory>
41       </Directory>
42       <Directory Id="VS90_PROJECTTEMPLATES_DIR">
43         <Directory Id="CSHARP90" Name="CSharp">
44           <Directory Id="PFOLDER90" Name="MySDK">
45             <Component Id="Template2008" Guid="????????-????-????-????-??????????">
46               <File Id="Template2008.zip_ID" Name="Template90.zip" DiskId="1" Source="Template90.zip"/>
47             </Component>
48           </Directory>
49         </Directory>
50       </Directory>
51       <Directory Id="GAC" Name="GAC">
52         <Component Id="WizardGac" Guid="????????-????-????-????-??????????">
53           <File Id=' It.Matteozan.MyWizard.dll' Name='It.Matteozan.MyWizard.dll' Source='It.Matteozan.MyWizard.dll ' Vital='yes' KeyPath='yes' Assembly='.net' ProcessorArchitecture='msil' />
54         </Component>
55       </Directory>
56
57     </Directory>
58
59     <Feature Id="AssemblySW" Title="SDK" Level="1">
60       <ComponentRef Id="WizardGac"/>
61     </Feature>
62     <Feature Id="InstallForVS2005" Title="SDK for 2005" Level="1">
63       <ComponentRef Id="Template2005" />
64       <Condition Level="0">NOT VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED</Condition>
65     </Feature>
66     <Feature Id="InstallForVS2008" Title="SDK for 2008" Level="1">
67       <ComponentRef Id="Template2008" />
68       <Condition Level="0">NOT VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED</Condition>
69     </Feature>
70
71     <InstallExecuteSequence>
72       <Custom Action="VS2005InstallVSTemplates" Before="InstallFinalize">
73         VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED
74       </Custom>
75       <Custom Action="VS90InstallVSTemplates" Before="InstallFinalize">
76         VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED
77       </Custom>
78     </InstallExecuteSequence>
79   </Product>
80 </Wix>

To install in the GAC the IWizard implementation in the GAC you can see line 51 - 55.

To interact to visual studio you should compile your wxs file with the WiXVSExtension. After that you can use PropertyRef to import in your file the relative property. I have used the follow properties VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED, VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED, VS2005_PROJECTTEMPLATES_DIR and VS90_PROJECTTEMPLATES_DIR. The properties that start with VS2005 are for Visual Studio 2005 and the other with VS90 are for Visual Studio 2008.

The first two properties VS2005_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED and VS90_IDE_VCSHARP_PROJECTSYSTEM_INSTALLED are used to detect if the Visual Studio is installed and can handle a C# proejct.

The other two are used to install the templates in the correct folder of visual studio. This properties are used in the directory tag at line 33 and 42.

The last step is the Visual Studio installation of template. This task can be made via command line with the follow command line:

Devenv.exe /installvstemplates

But with WiX and VSExtension you can use a custom action VS2005InstallVSTemplates and VS90InstallVSTemplates, used at line 72 and 75.

Tags: ,

2 Responses to “Make WiX setup for a Wizard of Visual Studio”

  1. Anonymous Says:

    Thanks your message has very much helped me:)

  2. Hosting Says:

    Interesting article, adding it to my boomarks!

Leave a Reply