Wix Harvest:当文件位于不同的文件夹中时,相同的组件/文件ID [英] Wix Harvest: Same Component/File ID when files are in different folders

查看:83
本文介绍了Wix Harvest:当文件位于不同的文件夹中时,相同的组件/文件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我可能没有正确执行此操作,但它确实可以解决:

So I may not be doing this correct, but here it goes:

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

I have one application with references to 4 SQL Server assemblies

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

App must work against SQL 2008 and 2010.

使它起作用的唯一方法是让我的应用程序为我的SQL程序集引用一个通用"路径.然后在我的MSBuild项目中,我将2008程序集复制到通用"文件夹并编译我的应用程序.我将在2012年再次进行此操作.

The only way I've gotten this to work is, to have my app reference a 'generic' path for my SQL Assemblies. Then in my MSBuild project, I copy the 2008 assemblies to the 'generic' folder and compile my app. I do this again for the 2012.

我有一个文件夹,如Tools \ Release \ V2008和Tools \ Release \ V2010.这些文件夹具有所有EXE和必需的DLL(包括4 sql服务器).我对这些文件夹运行HEAT.

I have a folder like Tools\Release\V2008 and Tools\Release\V2010. These folders have all the EXE and required DLLs (including the 4 sql server). I run HEAT against these folders.

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

However, when I run heat against each folder, with each having the same directory ID but different Component, I get 2 wxs files, each have the same files (expected) but each the component and file ids are identical in the 2 wxs files.

示例:

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? 或者-我该如何做得更好:)

How can I get each WXS file to have unique component and file IDs? Or - How can I do this better :)

谢谢!

推荐答案

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

The ID will be the same because you are using -srd, suppress root directory. In this case, the path used for generating the ID will be only the filename, generating the same ID for files with same name.

您有两种选择:

1)执行加热以使用-t收获文件时,请使用转换权.

1) Use a transform right when you execute heat to harvest the files with -t.

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

2) Use XslTransform task (.NET 4) after harvesting to rename the ID to one like File_2012_AL3Util and File_2008_AL3Util.

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

You can apply this XSL to your file. In the example below, the element will be removed if it matches 'MyFile' for file name and 'MyID' for directory id.

<?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>

这篇关于Wix Harvest:当文件位于不同的文件夹中时,相同的组件/文件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆