【问题标题】:Wix Bundle Source path and project stuctureWix Bundle 源路径和项目结构
【发布时间】:2015-06-24 16:05:52
【问题描述】:

我正在尝试创建一个 Bootstrapper 安装程序,它将安装我的应用程序以及运行我的应用程序所需的一个第三方应用程序。

第三方应用程序是一个带有大量补充文件的 .exe 包。

我的问题是,如何将第三方应用程序包含到我的 Bundle 中?我是否也将所有补充文件(100 多个文件)添加为有效负载?

下面的代码是我到目前为止设置我的 Bundle 的方式,它正在编译但没有安装,日志说引导程序 .exe 找不到我的 .msi(我的应用程序)或 .exe(第三方应用程序)

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Bundle Name="My_app"
            Version="1.0.0.0"
            Manufacturer="untitled"
            UpgradeCode="4d2de235-2286-4b06-8cfa-3f6ff3174244">

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />

        <Chain>
            <MsiPackage
                Id="MyApp_msi"
                SourceFile ="MyApp\MyApp.msi"
                Vital ="yes"/>
            <PackageGroupRef Id="thirdParty_package" />
        </Chain>
    </Bundle>

    <Fragment>
        <PackageGroup Id="thirdParty_package">
            <ExePackage
                SourceFile="thirdParty\Setup.exe"
                InstallCommand="/q /ACTION=Install"
                RepairCommand="/q ACTION=Repair /hideconsole"
                UninstallCommand="/q ACTION=Uninstall /hideconsole"/>
        </PackageGroup>
    </Fragment>
</Wix>

【问题讨论】:

  • 愚蠢的问题...您引用的目录(MyApp 和第三方)是否在同一目录中,该目录与您的安装程序项目的工作目录相同?看起来您的工作目录与您认为的不同(或者那些文件确实不存在)
  • WiX 先生 - Rob - 在这里回答:windows-installer-xml-wix-toolset.687559.n2.nabble.com/…

标签: wix installation bootstrapper


【解决方案1】:

是的,您必须列出每个有效负载。将它们放在 PayloadGroup 中很方便。

有很多方法可以生成 PayloadGroup。一种方法是使用/滥用热量来获取目录。这与为安装项目获取目录的方式相同。

作为一个例子,让我们打包 WiX 的 bin 目录。

  <ExePackage Id="MyPackageId" SourceFile="$(env.WiX)bin/dark.exe" Compressed="yes">
    <PayloadGroupRef Id="MyPayloadGroupId"/>
  </ExePackage>

如果您使用的是 MSBuild(包括通过 Visual Studio),您可以通过在项目文件中添加类似这样的内容来配置收获:

  <ItemGroup>
    <HarvestDirectory Include="$(WIX)/bin">
      <ComponentGroupName>MyPayloadGroupId</ComponentGroupName>
      <PreprocessorVariable>var.MyPayloadSourceDirectory</PreprocessorVariable>
      <Transforms>FilesToPayloads.xsl</Transforms>
      <SuppressRegistry>true</SuppressRegistry>
      <!-- Hide from VS Solution Explorer -->
      <InProject>false</InProject>
    </HarvestDirectory>
  </ItemGroup>

当构建运行时,它会将输出 .wsx(在 obj 中)文件夹添加到构建中。 (你不需要看到它。)

请注意,它使用预处理器变量来提供源文件的实际位置。要传递值,请在项目属性中定义它。或者,作为 .wixproj 中的 XML:

<DefineConstants>Debug;MyPayloadSourceDirectory=C:/Program Files (x86)/WiX Toolset v3.8/bin</DefineConstants>

最后,XSL 转换 (FilesToPayloads.xsl) 将热量应用于其正常的收获输出:

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
  xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:template match="/">
    <Wix>
      <Fragment>
        <xsl:apply-templates select="*" />
      </Fragment>
    </Wix>
  </xsl:template>

  <xsl:template match="//wix:DirectoryRef">
    <PayloadGroup>
      <xsl:attribute name="Id">
        <xsl:value-of select="/wix:Wix/wix:Fragment/wix:ComponentGroup/@Id"/>
      </xsl:attribute>
      <xsl:apply-templates select="*" />
    </PayloadGroup>
  </xsl:template>

  <xsl:template match="//wix:File">
    <Payload>
      <xsl:attribute name="SourceFile">
        <xsl:value-of select="@Source"/>
      </xsl:attribute>
    </Payload>
  </xsl:template>

</xsl:stylesheet>

这是 File 到 Payload 和周围的 DirectoryRef 到 PayloadGroup 的相当简单的音译。

【讨论】:

【解决方案2】:

同意为具有许多文件的安装程序手动生成有效负载很痛苦! 这是一个小的 powershell 脚本,用于在给定路径的情况下生成有效负载 xml。它将生成用作 id 的 guid,递归文件夹并重现文件夹结构。

if($args.Length -eq 0) {
    Write-Host "Error: No argument. Supply path to payload folder as script argument."
    Exit 1
}
$path = $args[0]
foreach($file in Get-ChildItem -Name $path -File -Recurse)
{
    Write-Host ("<Payload Id=`"" + ([guid]::NewGuid()) + "`" SourceFile=`"" + (Join-Path -Path $path -ChildPath $file) + "`" Name=`"" + $file + "`" />")
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-28
    • 2014-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多