Wednesday 8 July 2015

Windows Installer XML in VS2013 – WIX

Introduction

The Windows Installer XML (WiX) is a toolset that builds Windows installation packages from XML source code. The toolset supports a command line environment that developers may integrate into their build processes to build MSI and MSM setup packages.

Getting Started With WIX

Step 1 : Add Windows Installer Project



Step 2: Add a reference of the WPF Application

 

Step 3: Configure the installation of the XML file (*.WXS)

While you see the *.wxs file it has some predefined code written in XML. It has various properties and tags for configure
 

Note:
You must provide the new GUID for every Component . You can do that very easily from Visual Studio.
Click on “Tools” and click on “Create GUID”; it creates a new GUID every time.



Step 4: Add WPF project to the *.WXS File

We need to give a reference of the WPF Application project in the *.WXS file. So that we can use the variables of the WIX . you can see ( about variables ) this on the link WiX Project Reference Variables
 


Step 5: Add Cab1.cab File inside the Package
 
When you build you WIX project it will create a Cab1.cab file and a *.setup so if we need only one single file for the setup add that time we need to add that file to our setup file. 

Step 6: Create Folder ( Program Files Folders , Desktop and Start-up )

 


Step 7: Add shortcut of application with icon

<!– Step 1.1: Add the shortcut to your installer package Program Menu or Start Menu–>
    <DirectoryRef Id=”ApplicationProgramsFolder”>
      <Component Id=”ApplicationShortcut” Guid=”Guid Here″>
        <!–Add Shortcut of the Application in start Menu–>
        <Shortcut Id=”ApplicationStartMenuShortcut” Name=”VMS” Description=”My Application Description”
            Target=”[INSTALLFOLDER]appName.exe” WorkingDirectory=”INSTALLFOLDER”>

          <!–Add Icon to the ShortCut–>
          <Icon Id=”MYPMenuIcon”  SourceFile=”.\Images\blabla.ico” />
        </Shortcut>

        <!–Remove the Folder At time of Uninstall–>
        <RemoveFolder Id=”ApplicationProgramsFolder” On=”uninstall”/>
        <RegistryValue Root=”HKCU”  Key=’Software\[Manufacturer]\[ProductName]’
                       Name=”installed” Type=”integer” Value=”1″ KeyPath=”yes”/>
      </Component>
    </DirectoryRef>

 <!– Step 2.1: Add the shortcut to your installer package For DeskTop–>
 <DirectoryRef Id=”DesktopFolder”>
      <Component Id=”ApplicationDeskShortcutComp” Guid=”Guid Here”>
        <Condition>INSTALLDESKTOPSHORTCUT</Condition>       
        <Shortcut Id=”ApplicationDeskShortcut” Name=”VMS”
                  Description=”My Application Description” Target=”[INSTALLFOLDER]VMS.exe”
                  WorkingDirectory=”INSTALLFOLDER”>         
          <Icon Id=”MYDeskIcon”  SourceFile=”.\Images\blabla.ico” />
        </Shortcut>       
        <RemoveFolder Id=”DesktopFolder” On=”uninstall”/>       
        <RegistryValue Root=”HKCU”  Key=’Software\[Manufacturer]\[ProductName]’
                       Name=”installed” Type=”integer” Value=”1″ KeyPath=”yes”/>       
      </Component>
    </DirectoryRef>

    <!–Step 3.1: add Shortcut to StartUp Folder to run application when you login–>
    <DirectoryRef Id=”StartupFolder”>
      <Component Id=”ApplicationStartUpShortcutComp” Guid=”GUid Here”>
        <Shortcut Id=”ApplicationStartUpDeskShortcut” Name=”AppName” Description=”My Application Description”
            Target=”[INSTALLFOLDER]VMS.exe” WorkingDirectory=”INSTALLFOLDER”>
          <Icon Id=”MyIconStartUp”  SourceFile=”.\Images\blabla.ico” />
        </Shortcut>
        <RemoveFolder Id=”StartupFolder” On=”uninstall”/>
        <RegistryValue Root=”HKCU”  Key=’Software\[Manufacturer]\[ProductName]’
                       Name=”installed” Type=”integer” Value=”1″ KeyPath=”yes”/>
      </Component>
    </DirectoryRef>

Step 8: Add Folders/Files/Dlls to INSTALLFOLDER
 

 Step 9: Add component to Features