如果不添加WixVariables WixMbaPrereqPackageId
和WixMbaPrereqLicenseUrl
,则编译失败。
The Windows Installer XML variable
!(wix.WixMbaPrereqPackageId)
is unknown.
The Windows Installer XML variable!(wix.WixMbaPrereqLicenseUrl)
is unknown.
如果添加这两个变量,即使我的测试计算机安装了 .NET Framework 4.0, Bootstrap 每次都会安装 .NET Framework 4.0。
当目标计算机已安装.NET Framework时,如何避免安装.NET Framework?
下面是我的示例代码。
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Name="TestBootstrapper" Version="1.0.0.0" Manufacturer="Microsoft" UpgradeCode="e8c02687-b5fe-4842-bcc4-286c2800b556">
<BootstrapperApplicationRef Id='ManagedBootstrapperApplicationHost'>
<Payload SourceFile='MyBA.dll' />
</BootstrapperApplicationRef>
<!--<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />-->
<Chain>
<PackageGroupRef
Id="Netfx4Full"/>
<MsiPackage Name="SetupProject1.msi" SourceFile="data\SetupProject1.msi" DownloadUrl="http://myserver/SetupProject1.msi" Compressed="no">
</MsiPackage>
<MsiPackage Name="SetupProject2.msi" SourceFile="data\SetupProject2.msi" DownloadUrl="http://myserver/SetupProject2.msi" Compressed="no">
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<WixVariable
Id="WixMbaPrereqPackageId"
Value="Netfx4Full" />
<WixVariable
Id="WixMbaPrereqLicenseUrl"
Value="NetfxLicense.rtf" />
<util:RegistrySearch
Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
Value="Version"
Variable="Netfx4FullVersion" />
<util:RegistrySearch
Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
Value="Version"
Variable="Netfx4x64FullVersion"
Win64="yes" />
<PackageGroup Id="Netfx4Full">
<ExePackage
Id="Netfx4Full"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile="dotNetFx40_Full_x86_x64.exe"
DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" />
</PackageGroup>
</Fragment>
</Wix>
最佳答案
您缺少 Burn 启动自定义 BA 所需的一些配置。如果 BA 的初始化和加载失败,它将启动先决条件安装程序。在你的例子中是.Net Framework。
您必须添加“BootstrapperCore.config”文件作为有效负载才能运行自定义 BA。 BoostrapperCore.config 告诉刻录引擎如何初始化您的自定义 BA。
您的 BootstrapperApplicationRef 应如下所示
<BootstrapperApplicationRef Id='ManagedBootstrapperApplicationHost'>
<Payload SourceFile='MyBA.dll' />
<Payload SourceFile='BootstrapperCore.config' />
</BootstrapperApplicationRef>
BootstrapperCore.config 文件的内容:
<configuration>
<configSections>
<sectionGroup name="wix.bootstrapper"
type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore">
<section name="host"
type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" />
</sectionGroup>
</configSections>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
<wix.bootstrapper>
<host assemblyName="MyBA">
<supportedFramework version="v4\Full" />
<supportedFramework version="v4\Client" />
</host>
</wix.bootstrapper>
</configuration>
将不带扩展名的程序集名称写入属性“AssemblyName”。
还要确保将以下条目添加到 BA 程序集的 assemblyinfo.cs 中,其中 MyNamespace.MyBA 是类的名称,包括从 WiXBootstrapper.BootstrapperApplication 派生的完整命名空间名称
[assembly: BootstrapperApplication(typeof(MyNamespace.MyBA))]
关于wix - 为什么托管 Bootstrap 应用程序总是安装 .Net 框架,无论 .net 框架是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16666478/