views:

289

answers:

1

I'm currently writing an installation for our in-house development SDK. Part of this SDK is a guidance package for Visual Studio 2008 (Guidance Framework Version: February 2008).

Unfortunately I have no idea how to write a WiX-installation for the guidance package created. How to do that?

By default the guidance-package-wizard in Visual Studio only supports creating a Visual Studio deployment project. Could this be useful?

I already tried to analyse the deployment project in order to find out what to do:

  • The deployment project calls an custom action. SourcePath for the action is an GuidanceInstaller.dll, CustomActionData is: /Configuration=”[TARGETDIR]Guidance.xml”,
  • GuidanceInstaller.dll is the output of a project which was also created by the Visual Studio package wizard. The project consists only of one class:

    using Microsoft.Practices.RecipeFramework;
    
    
    [System.ComponentModel.ToolboxItem(false)]
    public class InstallerClass : ManifestInstaller
    {
    }
    

    Seems for me that every install action is hidden in the ManifestInstaller class?

  • Guidance.xml is an XML file created by the DflGuidance wizard.

How to create an WiX installatin while from this information? Although alternative ideas are welcome! (One thought I had was to integrate the resulting msi/cab file from the Visual Studio deployment project in my WiX-Installation, is that possible?)

A: 

Pre-Condition Checks

Prerequisites are,

  1. Visual Studio 2008 IDE installation.
  2. Dotnet Framework 2.0 runtime
  3. GAX installation.

To check these, Reference these two DLLs:

  1. WixNetFxExtension (mostly from C:\Program Files\Windows Installer XML v3\bin\WixNetFxExtension.dll)
  2. WixUIExtension (mostly from C:\Program Files\Windows Installer XML v3\bin\WixUIExtension.dll)

and add preconditions to your .wxs file as shown below.

  <!-- Dotnet 2.0 framework installation check - START -->
  <PropertyRef Id="NETFRAMEWORK20" />
  <Condition Message="Framework 2.0 is required for the setup to continue."><![CDATA[INSTALLED or NETFRAMEWORK20]]></Condition>
  <!-- Dotnet 2.0 framework installation check - END -->

  <!-- VS.NET and VS.C# installation check - START -->
  <Property Id="VCSHARP">
    <RegistrySearch Id="VCShaprp" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\9.0\InstalledProducts\Microsoft Visual C#" Name="Package" Type="raw" />
  </Property>
  <Condition Message="Please install Visual C# with Visual Studio 2008 to continue. Setup will now abort."><![CDATA[INSTALLED or VCSHARP]]></Condition>
  <!-- VS.NET and VS.C# installation check - END -->


  <!-- GAX for VS.2008 installation check - START -->
  <Property Id="GAX">
    <RegistrySearch Id="gax" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\9.0\InstalledProducts\RecipeManagerPackage" Name="Package" Type="raw" />
  </Property>
  <Condition Message="Please install Guidance Automation Extension on Visual Studio 2008 to continue. Setup will now abort."><![CDATA[INSTALLED OR GAX]]></Condition>
  <!-- GAX for VS.2008 installation check - END -->

  <!-- Pre-requisite check - END -->

Installation Folder

Define run time installation folder setup. This link will help you to answer all your "how to"s.

Running Installer

You have to modify your InstallerClass as shown below.

[System.ComponentModel.ToolboxItem(false)]
    [RunInstaller(true)]
public class InstallerClass : ManifestInstaller
{
    public InstallerClass()
        : base()
    { }

    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
    }

    public override void Commit(System.Collections.IDictionary savedState)
    {
        base.Commit(savedState);
    }

    public override void Rollback(System.Collections.IDictionary savedState)
    {
        base.Rollback(savedState);
    }
}

Without this WIX installer throws an exception saying no class are marked as "RunInstaller"

After this you can use below WIX elements to run installutil.exe to run your installer class.

  <InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
    <Custom Action="ManagedInstall" After="InstallFinalize" >NOT Installed</Custom>
    <Custom Action="ManagedUnInstall" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
  </InstallExecuteSequence>

  <CustomAction Id="ManagedInstall"
              Directory='INSTALLLOCATION'
              ExeCommand='"[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\installUtil.exe" /LogToConsole=false /DesignMode /hive=9.0 /Configuration=&quot;[INSTALLLOCATION]Guidance.xml&quot; &quot;[INSTALLLOCATION]PackageInstaller2008.dll&quot;' 
              Return='check' >
  </CustomAction>

  <CustomAction Id="ManagedUnInstall"
              Directory='INSTALLLOCATION'
              ExeCommand='"[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\installUtil.exe" /u /LogToConsole=false /DesignMode /hive=9.0 /Configuration=&quot;[INSTALLLOCATION]Guidance.xml&quot; &quot;[INSTALLLOCATION]PackageInstaller2008.dll&quot;'
              Return='check' >
  </CustomAction>

Hope this helps.

Pavan G R

related questions