【问题标题】:Setup created by WiX bootstrapper is not startedWiX 引导程序创建的安装程序未启动
【发布时间】:2013-05-06 08:38:31
【问题描述】:

我尝试使用 Bootstrapper 创建一个设置文件,该文件旨在首先运行 .NET 框架设置文件,然后才运行 MyApp.exe。完成项目后,我得到了最终的设置文件,但即使在选择文件后双击或按回车后也无法启动。我不知道我错在哪里。

这是program.cs 文件:

using Microsoft.Tools.WindowsInstallerXml.Bootstrapper;
namespace testingBoot
{
    class Program:BootstrapperApplication
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is tesing for the bootStrapper");
            Console.Read();
        }

        protected override void Run()
        {
            throw new NotImplementedException();
        }
    }
}

我的 WiX 安装文件在这里

<?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 UpgradeCode="46C265F4-3F60-4781-9EF6-DB889C115D55" Version="1.0.0.0">
        <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
            <Payload SourceFile="BootstrapperCore.config" />
            <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.7\SDK\Microsoft.Deployment.WindowsInstaller.dll" />
        </BootstrapperApplicationRef>
        <Variable Name="LaunchTarget"
            Value="[ProgramFiles64Folder]Folder\Exe Name.exe"/>
        <Chain>
          <PackageGroupRef Id="Netfx4Full"/>
          <ExePackage SourceFile="$(var.PATH)\testingBoot.exe"/>
        </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="yes"
                        PerMachine="yes"
                        Permanent="yes"
                        Vital="yes"
                        Name="dotNetFx40_Full_x86_x64.exe"
                        SourceFile="dotNetFx40_Full_x86_x64.exe"
                        DetectCondition="VersionNT64" />
        </PackageGroup>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents"
                        Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
                <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->
        </ComponentGroup>
    </Fragment>
</Wix>

而且我还在配置文件BootstrapperCore.config 中将主机下的程序集名称更改为我自己的程序集名称testingBoot.exe

这是我的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" />
        <supportedRuntime version="v2.0.50727" />
    </startup>
    <wix.bootstrapper>
        <host assemblyName="testingBoot" >
            <supportedFramework version="v4\Full" />
        </host>
    </wix.bootstrapper>
</configuration>

【问题讨论】:

    标签: c# wix bootstrapper wix3.7


    【解决方案1】:

    BootstrapperApplicationRef 元素中似乎缺少您的 BootstrapperApplication 程序集。我还应该注意,Burn 引擎会直接加载您的 BA 程序集。它不会将其作为可执行文件启动。因此,要加载您的 BootstrapperApplication,我认为您需要进行以下更改:

    <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
    
      <Payload SourceFile="$(var.PATH)\testingBoot.exe"/>
      <Payload SourceFile="BootstrapperCore.config" />
    
      <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.7\SDK\Microsoft.Deployment.WindowsInstaller.dll" />
    </BootstrapperApplicationRef>
    

    这会将testingBoot.exe 添加到 BootstrapperApplication,如果您的BoostrapperCore.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="testingBoot">
            <supportedFramework version="v4\Full" />
            <supportedFramework version="v4\Client" />
        </host>
      </wix.bootstrapper>
    </configuration>
    

    然后,Burn 引擎将找到一个名为 testingBoot 的程序集并加载它。同样,如上所述,testingBoot 将被直接加载,Run() 方法将被直接调用。 Main() 入口点将被跳过,因为 Burn 引擎不会将程序集作为可执行文件运行。

    【讨论】:

    • 感谢您的回复。虽然它似乎更合理,但我在我的项目中尝试了这个但仍然有同样的问题,安装文件没有启动。我已经编辑了我的问题并添加了我的配置文件的详细信息。
    • encase 您需要有关我的项目的更多详细信息,我已在此处上传了我的项目 w.mediafire.com/download.php?em5e83p03jo8zsr 它在 VS2012 中并使用 WIX3.7。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    相关资源
    最近更新 更多