A.Pissicat
A.Pissicat

Reputation: 3295

Install packages with wix

I'm using wix for my C# project. I have a bootstrapper for the setup. This bootstrapper install :

My problem is that System Management Object 2014 is depending from CLR types 2014. When my setup is performing, SQL server is installed, then CLR types 2014 and when setup have to install System Management Object 2014 I have an error message "Needs CLR Types". If I cancel the setup and restart it works fine.

How can I write my Bundle.wxs to detect previous install (or reboot setup) ?

There is my code:

<!-- SQL CLR Types -->
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server 2014 Redist\SQL Server System CLR Types\CurrentVersion"
                     Value="Version"
                     Variable="CLRTypesx86"/>
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server 2014 Redist\SQL Server System CLR Types\CurrentVersion"
                     Value="Version"
                     Variable="CLRTypesx64"
                     Win64="yes"/>

<!-- System Managment Objects -->
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion"
                     Value="Version"
                     Variable="SMO2014x86"/>
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion"
                     Value="Version"
                     Variable="SMO2014x64"
                     Win64="yes"/>

<!-- Install SQL CLR Types -->
<PackageGroup Id="SQLCLRTypes">
  <MsiPackage Id="SQLCLRTypesx86"
              SourceFile=".\Resources\SQLSysClrTypes2014x86.msi"
              ForcePerMachine="yes"
              Cache="no"
              Compressed="no"
              DownloadUrl="https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x86/SQLSysClrTypes.msi"
              Permanent="no"
              Vital="yes"                  
              InstallCondition="NOT VersionNT64 AND NOT CLRTypesx86" />
  <MsiPackage Id="SQLCLRTypesx64"
              SourceFile=".\Resources\SQLSysClrTypes2014x64.msi"
              ForcePerMachine="yes"
              Cache="no"
              Compressed="no"
              DownloadUrl="https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x64/SQLSysClrTypes.msi"
              Permanent="no"
              Vital="yes"
              InstallCondition="VersionNT64 AND NOT CLRTypesx64" />
</PackageGroup>

<!-- Install System Managment Objects -->
<PackageGroup Id="SMO2014">
  <MsiPackage Id="SharedManagementObjects2014x86"
              SourceFile=".\Resources\SharedManagementObjects_x86.msi"
              ForcePerMachine="yes"
              Cache="no"
              Compressed="no"
              DownloadUrl="https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x86/SharedManagementObjects.msi"
              Permanent="yes"
              Vital="yes"
              InstallCondition="NOT VersionNT64 AND NOT SMO2014x86" />
  <MsiPackage Id="SharedManagementObjects2014x64"
              SourceFile=".\Resources\SharedManagementObjects_x64.msi"
              ForcePerMachine="yes"
              Cache="no"
              Compressed="no"
              DownloadUrl="https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x64/SharedManagementObjects.msi"
              Permanent="yes"
              Vital="yes"
              InstallCondition="VersionNT64 AND  NOT SMO2014x64" />
</PackageGroup>

Upvotes: 1

Views: 438

Answers (1)

Brian Sutherland
Brian Sutherland

Reputation: 4798

If your SQLCLRTypes install is requiring a restart it will notify the bootstrapper application that one is needed but the bootstrapper engine will decide to note that a restart is required and then continue with installing the other packages until the end of the install then the last page will show the restart page instead of the finish page and will have a restart button.

The bootstrapper also supports restarting in the middle of an install then continuing the install if necessary after the machine restarts. We can use this functionaity since a downstream package depends on SQLCLRTypes and this isn't fully present until a restart due to files in use most likely.

Since you are using C# I assume you are using the managed bootstrapper.

You'll need to add a handler to the OnExecutePackageComplete event that is raised after every package finishes.

It would probably look something like this

private void ExecutePackageComplete(object sender, ExecutePackageCompleteEventArgs args)
{
    if (e.Restart == ApplyRestart.RestartRequired && (e.PackageId == "SQLCLRTypesx86" || e.PackageId == "SQLCLRTypesx64"))
    {
        e.Result = Result.Restart
    }
}

This will cause your bootstrapper to show the restart page after installing SQLCLRTypes instead of continuing to try to install SMO. Once the machine restarts, the install will start up again automatically and resume where it left off. You may want to indicate with some additional text that the installation will resume after the restart on the restart page of your bootstrapper when SQLCLRTypes requires a restart.

Upvotes: 2

Related Questions