【问题标题】:Why does managed bootstrapper application always install .Net framework no matter the .net framework exists or not?为什么托管引导程序应用程序总是安装 .Net 框架,无论 .net 框架是否存在?
【发布时间】:2013-05-21 09:24:43
【问题描述】:

如果未添加 WixVariables WixMbaPrereqPackageIdWixMbaPrereqLicenseUrl,则编译失败。

Windows Installer XML 变量 !(wix.WixMbaPrereqPackageId) 未知。
Windows Installer XML 变量 !(wix.WixMbaPrereqLicenseUrl) 未知。

如果添加这两个变量,即使我的测试计算机安装了 .NET Framework 4.0,引导程序每次都会安装 .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>

【问题讨论】:

    标签: wix bootstrapper


    【解决方案1】:

    您缺少 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))]
    

    【讨论】:

      【解决方案2】:

      WIX Bootstrapper 在无法加载 MBA 时默认启动框架安装。使用简单的消息框检查您的 MBA 是否已加载。

      您可以在 Run() 函数中使用以下代码来确保这一点。

          protected override void Run()
          {
              this.Engine.Log(LogLevel.Verbose, "Running the TestBA.");
              MessageBox.Show("MBA is loaded");
              this.Engine.Quit(0);
          }
      

      确保您已在程序集信息文件中包含 MBA 类名称。

      [assembly: BootstrapperApplication(typeof(TestBA))]
      

      检查您在 %temp% 位置的引导程序日志文件以查找错误的根本原因。

      我参考了this 示例来启动引导程序应用程序。这可能对您有所帮助。

      【讨论】:

      • 感谢分享好例子,我的问题解决了,我没有在程序集信息文件中添加属性
      【解决方案3】:

      Burn 创建了一个日志——它说了什么?听起来您的 DetectCondition 是错误的。为什么不使用 .NET 的 WiX 包组?他们有正确的搜索和条件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-05-04
        • 2021-06-16
        • 1970-01-01
        • 1970-01-01
        • 2012-11-23
        • 2022-06-28
        • 1970-01-01
        相关资源
        最近更新 更多