【问题标题】:Wix Harvest: Same Component/File ID when files are in different foldersWix Harvest:当文件位于不同文件夹时,相同的组件/文件 ID
【发布时间】:2014-11-06 23:06:36
【问题描述】:

所以我可能做的不对,但这里是这样:

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

应用必须针对 SQL 2008 和 2010 运行。

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

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

但是,当我对每个文件夹运行 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>

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

谢谢!

【问题讨论】:

  • 我正在执行以下命令并且得到不同的 ID:heat dir c:\temp\Dir1 -o c:\temp\dir1output.wxs。您使用的命令语法如何?

标签: wix heat harvest


【解决方案1】:

ID 将相同,因为您使用的是-srd,取消根目录。在这种情况下,用于生成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>

【讨论】:

  • 我会试试的 - 谢谢!!
猜你喜欢
  • 1970-01-01
  • 2013-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-22
  • 2013-06-21
  • 2014-04-06
  • 1970-01-01
相关资源
最近更新 更多