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

c#-微星安装程序

(c# - MSI Installer)

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

我在使用 SAP Crystal Reports SDK 时遇到了问题。它从网络上消失了,所以我不得不创建自己的ClickOnce Bootstrapper软件包(为此我使用了名为Bootstrap生成器的软件)。

它几乎按预期工作,它在安装主程序之前安装SAP Crystal Report。

问题是每次我运行安装程序时它都在安装SAP Crystal Report,即使它已经安装。

看起来我的MSI安装程序没有检测到已经安装了SAP水晶报告的版本。

产品.xml如下所示:

<?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>

包.xml如下所示:

<?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>

先决条件属性:

在此处输入图像描述

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

如果要检查是否已安装必备组件,则需要向产品.xml文件添加 2 项内容。第一件事是产品代码或注册表项。如果选择产品代码,则可以添加 MSI 安装检查,例如:

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

然后,你必须添加安装条件,例如(对于 x86):

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

请注意,CR32BitExists 在安装检查中声明,并在安装条件中使用。关于使用的值 (1,3),你可以在此处阅读:

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

修改产品后.xml你需要重建你的 MSI。当你尝试安装它时,它将在安装检查中查找提到的产品代码。如果它检测到它安装在操作系统中,它将绕过安装。