WIX:多个功能/文件夹的重复 ID 问题

发布于 2024-09-19 06:19:27 字数 1307 浏览 1 评论 0原文

我是 Wix 的新手,正在创建一个多功能 Wix 项目。我们的产品有 4 个模块,每个模块都必须作为一项功能包含在 Windows 安装程序中。但所有功能都共享相同的文件夹结构。

我正在使用命令行构建我的 Wix 项目。将每个模块收集到不同的 wxs 片段中后,light.exe 会给出错误,指出目录表中存在重复的 id。

我的文件树看起来像...

    ModuleA - Core
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- a.txt

ModuleB
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- b.txt

ModuleC 
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- c.txt

我正在使用以下命令...

@echo Harvesting target files....
heat.exe dir .\Mod1 -cg Mod1ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod1files -out Mod1Files.wxs

heat.exe dir .\Mod2 -cg Mod2ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod2files -out Mod2Files.wxs

heat.exe dir .\Mod3 -cg Mod3ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod3files -out Mod3Files.wxs

@echo Compile modules....
candle.exe -nologo myproj.wxs Mod1Files.wxs Mod2Files.wxs Mod3Files.wxs -dmod1files =.\Mod1 -dmod2files=.\Mod2  -dmod3files=.\Mod3

@Creating MSI...
set msi_name=MYProduct.1.0.12345.Win32.msi

light.exe -nologo -ext WixUIExtension -cultures:en-us myproj.wixobj Mod1Files.wixobj Mod2Files.wixobj Mod3Files.wixobj -o %msi_name%

有什么方法可以避免重复 ID 错误?

任何帮助将不胜感激。

提前致谢。

穆图

I am newbie to Wix and creating a multi feature Wix project. Our product is having 4 modules and each module has to be included as a feature in the Windows installer. But all features are sharing the same folder structure.

I am using commandline to build my Wix project. After harvesting every module into different wxs fragments, the light.exe giving error saying that duplicate id in the dirercoty table.

My file tree is look like...

    ModuleA - Core
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- a.txt

ModuleB
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- b.txt

ModuleC 
 |--bin
 |--etc
 |   |--mgr
 |--lib
 |-- c.txt

I am using following commands...

@echo Harvesting target files....
heat.exe dir .\Mod1 -cg Mod1ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod1files -out Mod1Files.wxs

heat.exe dir .\Mod2 -cg Mod2ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod2files -out Mod2Files.wxs

heat.exe dir .\Mod3 -cg Mod3ComponentGroup -nologo -gg -scom -sfrag -sreg -srd -ke -dr INSTALLLOCATION -var var.mod3files -out Mod3Files.wxs

@echo Compile modules....
candle.exe -nologo myproj.wxs Mod1Files.wxs Mod2Files.wxs Mod3Files.wxs -dmod1files =.\Mod1 -dmod2files=.\Mod2  -dmod3files=.\Mod3

@Creating MSI...
set msi_name=MYProduct.1.0.12345.Win32.msi

light.exe -nologo -ext WixUIExtension -cultures:en-us myproj.wixobj Mod1Files.wixobj Mod2Files.wixobj Mod3Files.wixobj -o %msi_name%

Is there any way to avoid the Duplicate ID error?

Any help would be really appreciated.

Thanks in Advance.

Muthu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

等风也等你 2024-09-26 06:19:27

如果您使用合并模块,这没问题,因为每个 ID 都会附加一个唯一的模块 ID。 ( dir1.GUIDA, dir1.GUIDB, dir1.GUIDC ) 如果您使用片段,则必须更改 ID 或将目录结构规范化为单个 wxs,并使用 DirectoryRef 将其拉入包含组件的其他 wxs 中。

我不确定 Heat 能否自动处理所有这些。这实际上只是一个起点。

If you were using Merge Modules this would be ok because each ID would be appended with a unique module ID. ( dir1.GUIDA, dir1.GUIDB, dir1.GUIDC ) If you are using fragments you either have to change the ID's or normalize the directory structure into a single wxs and use a DirectoryRef to pull it into your other wxs with your components.

I'm not sure Heat can handle all of this automatically. It's really just more of a starting point.

多彩岁月 2024-09-26 06:19:27

我还遇到了一个问题,即我会根据最终位于同一目标安装文件夹中的文件夹生成多个组件组。

如果您安装了 cygwin 来使用 unix 工具,我为消除这些重复的 ID 所做的就是在每个 heat.exe 命令行后使用“sed”为所有 id 添加前缀。我只是将这些 sed 命令添加到 WIX 预构建步骤中,就像 heat 命令一样。

例如:

sed -i 's/Directory\ Id=\"/Directory\ Id\"mod1/g' " generatedfile.wxs"

此命令行会将所有 ( Directory Id="..." ) 替换为 ( Directory Id ="mod1..." )

它效果很好,因为这些目录没有被引用,而只是包含在组件中,然后在组中引用。

希望有帮助

I also had the problem where I would generate multiple component groups based on folders that would end up in the same target installation folders.

If you have cygwin installed to make use of unix tools, what I did to eliminate those duplicate IDs is to use "sed" after each heat.exe command line to add a prefix to all the ids. I just add those sed commands to be part of the WIX pre-build step just like the heat ones.

For example:

sed -i 's/Directory\ Id=\"/Directory\ Id\"mod1/g' "generatedfile.wxs"

This command line would replace all ( Directory Id="..." ) by ( Directory Id="mod1..." )

It works great because those directory are not referenced but just included in the components which then are referenced in groups.

Hope that helps

怀念你的温柔 2024-09-26 06:19:27

老问题,但我找到了解决方案,所以我回来分享给其他人。

问题是,如果您有多个具有相同目录结构的项目,则 Heat.exe 生成的唯一 ID 往往会发生冲突。

“HeatDirectory”元素有一个“Transform”选项,允许您定义一个可以向每个 ID 添加前缀的 XSLT 文件。如果您直接使用 Heat.exe 工具,则标志为“-t”。这是一个很好的工作示例:https://www.titanwolf.org/Network/q/c8bad204-3629-4e6e-8832-0ed17f23b1b4/y

<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"
exclude-result-prefixes="xsl wix">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

...

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

...

<xsl:template match="wix:Component/wix:File">
    <xsl:copy-of select="." />
    <RegistryValue Root="HKCU" Key="Software\Product" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</xsl:template>

<!--Give Compoentent ID prefix C_-->
<xsl:template match="wix:Component/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('C_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give Componentref ID prefix C_-->
<xsl:template match="wix:ComponentRef/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('C_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give Directory ID prefix Dir_-->
<xsl:template match="wix:Directory/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('Dir_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give File ID prefix File_-->
<xsl:template match="wix:File/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('File_', .)" />
    </xsl:attribute>
</xsl:template>

Old question, but I found a solution so I came back to share for others.

The problem is that the unique IDs generated by Heat.exe tend to collide if you have multiple projects with the same directory structure.

The 'HeatDirectory' element has a 'Transform' option that allows you to define an XSLT file that can add a prefix to every ID. If you are using the Heat.exe tool directly, the flag is '-t' Here is an excellent working example: https://www.titanwolf.org/Network/q/c8bad204-3629-4e6e-8832-0ed17f23b1b4/y

<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"
exclude-result-prefixes="xsl wix">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

...

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

...

<xsl:template match="wix:Component/wix:File">
    <xsl:copy-of select="." />
    <RegistryValue Root="HKCU" Key="Software\Product" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</xsl:template>

<!--Give Compoentent ID prefix C_-->
<xsl:template match="wix:Component/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('C_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give Componentref ID prefix C_-->
<xsl:template match="wix:ComponentRef/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('C_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give Directory ID prefix Dir_-->
<xsl:template match="wix:Directory/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('Dir_', .)" />
    </xsl:attribute>
</xsl:template>

<!--Give File ID prefix File_-->
<xsl:template match="wix:File/@Id">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat('File_', .)" />
    </xsl:attribute>
</xsl:template>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文