Wix Harvest:文件位于不同文件夹时的相同组件/文件ID

use*_*596 2 wix heat harvest

所以我可能不会这样做,但在这里:

我有一个应用程序引用4个SQL Server程序集

应用程序必须适用于SQL 2008和2010.

我让这个工作的唯一方法是让我的应用程序引用我的SQL程序集的"通用"路径.然后在我的MSBuild项目中,我将2008程序集复制到'generic'文件夹并编译我的应用程序.我在2012年再次这样做.

我有一个像Tools\Release\V2008和Tools\Release\V2010这样的文件夹.这些文件夹包含所有EXE和所需的DLL(包括4个sql server).我对这些文件夹运行HEAT.

但是,当我对每个文件夹运行热量时,每个文件夹具有相同的目录ID但不同的组件,我得到2个wxs文件,每个文件具有相同的文件(预期),但每个文件组件和文件ID在2个wxs文件中是相同的.

例:

MSBuild Command:
    <Exec Command="&quot;$(WixTools)\heat.exe&quot; dir $(DeploymentRoot)\Tools\V2008 -dr TOOLS -cg Tools2008Component -var var.Tools2008Path -gg -scom -sreg -sfrag -srd  -o $(heatOutputPath)\cmp2008ToolsFrag.wxs"/>    

WXS File
    <DirectoryRef Id="TOOLS">
        <Component Id="cmp04831EC1F8BB21C028A7FC875720302F" Guid="*">
            <File Id="fil09727A8BFD32FDCE7C743D6DD2008E7C" KeyPath="yes" Source="$(var.Tools2008Path)\AL3Util.exe" />
        </Component>

MSBuild Command:
        <Exec Command="&quot;$(WixTools)\heat.exe&quot; dir $(DeploymentRoot)\Tools\V2012 -dr TOOLS -cg Tools2012Component -var var.Tools2012Path -gg -scom -sreg -sfrag -srd  -o $(heatOutputPath)\cmp2012ToolsFrag.wxs"/>

WXS file
    <DirectoryRef Id="TOOLS">
        <Component Id="cmp04831EC1F8BB21C028A7FC875720302F" Guid="*">
            <File Id="fil09727A8BFD32FDCE7C743D6DD2008E7C" KeyPath="yes" Source="$(var.Tools2012Path)\AL3Util.exe" />
        </Component>
Run Code Online (Sandbox Code Playgroud)

如何让每个WXS文件具有唯一的组件和文件ID?或者 - 我怎样才能做得更好:)

谢谢!

Mar*_*los 5

由于您正在使用-srd,因此ID将是相同的,禁止根目录.在这种情况下,用于生成ID的路径将只是文件名,为具有相同名称的文件生成相同的ID.

你有两个选择:

1)在执行加热以使用时收集文件时使用转换-t.

2)在收获后使用XslTransform任务(.NET 4)将ID重命名为File_2012_AL3Util和File_2008_AL3Util.

您可以将此XSL应用于您的文件.在下面的示例中,如果元素与文件名的"MyFile"和目录ID的"MyID"匹配,则将删除该元素.

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

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <!-- Matches both directory name and file name. -->
  <!-- Matches any Component that has its @Directory with same @Id as Directory 'MyID'. -->
  <!-- Function ends-with does not work with heat. -->
  <xsl:template match="//wi:Component[@Directory=//wi:Directory[@Name='MyID']/@Id and substring(wi:File/@Source, string-length(wi:File/@Source) - string-length('MyFile') + 1) = 'MyFile']" />

</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)