Warm tip: This article is reproduced from serverfault.com, please click

MSI Installer

发布于 2022-01-24 19:04:56

I had a problem with SAP Crystal Reports SDK. It disappeared from web, so i had to create my own ClickOnce Bootstrapper package (for that I've used software called Bootstrap generator).

And its almost working as expected, it install SAP Crystal Report before installing main program.

The problem is that it is installing SAP Crystal Report everytime i run installer, even when its already installed.

It looks like my MSI installer doesnt detect that there is already installed version of SAP Crystal Report.

Product.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="SAP.Crystal.reports.x86" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <PackageFiles CopyAllPackageFiles="false">
    <PackageFile Name="crruntime_32bit_13_0_15.msi" PublicKey="3082010A0282010100A5F02AFCBAF295DD82C482B0AA83782A08EA007635AFE2E76B57558D6AD708A1C96B86DA81894CDBB42214C26674A5C7F233D8BC76C77B3B2CBC8E38033C3C9C26FC5CD0789A462A2A6B2B19AC9321C851A08544DBF42CE697C97B730964C159D533BA56B835B702AA3F30E96CFD76F60A555EBC862828347E468BF126B9EB345A7E488AEA3451E9E9EB8412A600D1DB811A2C0144697048CD41F100E10AB8225658E1C3B7613A06835E628E2556C0F8BFD1408A0A5FED97892F6B99F49F2F436A0293AA5562FBBD5EE89DC667261E058AA767E168867CEAC2081588C1BD800FC2BFCD98773CEFD3266F54EB0DC7DAF4D5CD1867EA897D39E6A289A4A75ECA890203010001" />
  </PackageFiles>
  <Commands Reboot="Defer">
    <Command PackageFile="crruntime_32bit_13_0_15.msi">
      <ExitCodes>
        <DefaultExitCode Result="Success" String="Anunexpectedexitcodewasr" FormatMessageFromSystem="true" />
      </ExitCodes>
    </Command>
  </Commands>
</Product>

Package.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Package Name="DisplayName" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <Strings>
    <String Name="Culture">pl</String>
    <String Name="DisplayName">SAP Crystal reports x86</String>
    <String Name="Anunexpectedexitcodewasr">An unexpected exit code was returned from the installer. The installation failed.</String>
  </Strings>
</Package>

Prerequsities properties:

enter image description here

Questioner
Bartosz Olchowik
Viewed
0
blackRose 2022-01-27 17:28:44

If you want to check if a prerequisite is already installed, you will need to add 2 things to the product.xml file. First thing is the product code, or registry key. If you pick a product code you could add an MSI Install check, for example:

<InstallChecks>
    <MsiProductCheck Property="CR32BitExists" Product="{9D52DBF3-229A-4723-BF31-C57C9C1D2A23}" />
    <MsiProductCheck Property="CR64BitExist" Product="{8055CFEA-3871-4C76-A321-E32F63637CC4}" />
  </InstallChecks>

Then you would have to add install conditions, for example (for x86):

<InstallConditions>
    <BypassIf Property="CR32BitExists" Compare="ValueEqualTo" Value="1" />
    <BypassIf Property="CR32BitExists" Compare="ValueGreaterThanOrEqualTo" Value="3" />
    <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel" />
</InstallConditions>

Notice that CR32BitExists is declared in Install checks and is used in InstallConditions. About used values (1,3) you can read about here:

https://learn.microsoft.com/en-us/windows/win32/msi/session-featurerequeststate

After modifying product.xml you need to rebuild your msi. When you try to install it, it will look for mentioned product codes in Install Checks. If it detects it installed in OS, it will bypass instalation.