A.Pissicat
A.Pissicat

Reputation: 3275

Manage prerequisites version in bootstrapper

I want to create a bootstrapper for an application C# with visualstrudio 2015. I want to set a prerequisite for SharedManagementObject (from Microsoft, downloaded that direct link). I followed the instructions on the microsoft website.

There is my product.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Product
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  ProductCode="Custom.Bootstrapper.SharedManagementObjects2014x86">

  <RelatedProducts>
    <DependsOnProduct Code="Custom.Bootstrapper.SQLSysClrTypes2014x86" />
  </RelatedProducts>

  <PackageFiles>
    <PackageFile Name="SharedManagementObjects2014x86.msi"/>
  </PackageFiles>

  <InstallChecks>
    <MsiProductCheck Product="IsMsiInstalled" 
      Property="{4E6202DE-B996-4736-A64B-09EE2A8469E6}"/>
  </InstallChecks>

  <Commands>
    <Command PackageFile="SharedManagementObjects2014x86.msi" Arguments="">

      <InstallConditions>
        <BypassIf Property="IsMsiInstalled"
          Compare="ValueGreaterThan" Value="0"/>
        <FailIf Property="AdminUser" 
          Compare="ValueNotEqualTo" Value="True"
         String="NotAnAdmin"/>
      </InstallConditions>

      <ExitCodes>
        <ExitCode Value="0" Result="Success"/>
        <ExitCode Value="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" String="GeneralFailure"/>
      </ExitCodes>
    </Command>
  </Commands>
</Product>

On setup, a dialog box correctly ask to install SharedManagementObjects2014x86.msi but I have 2 problems :

Tank you

Upvotes: 0

Views: 952

Answers (1)

A.Pissicat
A.Pissicat

Reputation: 3275

I finally found the answer

  • To not reinstall : Check registry

  • To install depending on CPU : check ProcessorArchitecture

My code :

<?xml version="1.0" encoding="utf-8" ?>
<Product
    xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
    ProductCode="Custom.Bootstrapper.SharedManagementObjects2014">

    <RelatedProducts>
        <DependsOnProduct Code="Custom.Bootstrapper.SQLSysClrTypes2014" />
    </RelatedProducts>

    <PackageFiles>
        <PackageFile Name="SharedManagementObjects2014x64.msi"/>
        <PackageFile Name="SharedManagementObjects2014x86.msi"/>
    </PackageFiles>

    <InstallChecks>
        <!-- Check registry -->
        <RegistryCheck Property="IsMsiInstalled"
         Key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion"
         Value="Version" />
    </InstallChecks>

    <Commands>
        <!-- Install for x86 : ProcessorArchitecture = Intel -->
        <Command PackageFile="SharedManagementObjects2014x86.msi" Arguments="">    
            <InstallConditions>
                <BypassIf Property="IsMsiInstalled"
                 Compare="ValueGreaterThan" Value="0"/>
                <BypassIf Property="ProcessorArchitecture"
                 Compare="ValueNotEqualTo" Value="Intel"/>
                <FailIf Property="AdminUser" 
                 Compare="ValueNotEqualTo" Value="True"
                 String="NotAnAdmin"/>
            </InstallConditions>

            <ExitCodes>
                <ExitCode Value="0" Result="Success"/>
                <ExitCode Value="1641" Result="SuccessReboot"/>
                <ExitCode Value="3010" Result="SuccessReboot"/>
                <DefaultExitCode Result="Fail" String="GeneralFailure"/>
            </ExitCodes>
        </Command>

        <!-- Install for x64 : ProcessorArchitecture = amd64 -->
        <Command PackageFile="SharedManagementObjects2014x64.msi" Arguments="">    
            <InstallConditions>
                <BypassIf Property="IsMsiInstalled"
                 Compare="ValueGreaterThan" Value="0"/>
                <BypassIf Property="ProcessorArchitecture"
                 Compare="ValueNotEqualTo" Value="amd64"/>
                <FailIf Property="AdminUser" 
                 Compare="ValueNotEqualTo" Value="True"
                 String="NotAnAdmin"/>
            </InstallConditions>

            <ExitCodes>
                <ExitCode Value="0" Result="Success"/>
                <ExitCode Value="1641" Result="SuccessReboot"/>
                <ExitCode Value="3010" Result="SuccessReboot"/>
                <DefaultExitCode Result="Fail" String="GeneralFailure"/>
            </ExitCodes>
        </Command>
    </Commands>
</Product>

Upvotes: 1

Related Questions