2

使用 WIX,并尝试安装两个相同的程序集,一个用于.Net35,另一个用于.Net40。我正在使用两个单独的组件,但是 WIX 阻止了项目的编译。

        <Directory Id="GAC40" Name="GAC">
            <Component Id="MyDllServicesModuleGac40Component" Guid="307675AA-8AEC-473B-A78A-FB362CCEDE2A" Win64="yes">
                <File Id="MyDllNet40DllGac" Name="MyDll.dll" KeyPath="yes" Assembly=".net" Source="..\MyDll\bin\Net40\MyDll.dll" />
            </Component>
        </Directory>
        <Directory Id="GAC35" Name="GAC">
            <Component Id="MyDllServicesModuleGac35Component" Guid="47E6BD1B-25CD-466D-945E-06DCF0F2A269" Win64="yes">
                <File Id="MyDllNet35DllGac" Name="MyDll.dll" KeyPath="yes" Assembly=".net" Source="..\MyDll\bin\Net35\MyDll.dll" />
            </Component>
        </Directory>

我收到的错误是:

错误 29 ICE30:目标文件“MyDll.dll”由 SFN 系统上的两个不同组件安装在“[TARGETDIR]\GAC\”中:“MyDllServicesModuleGac40Component.DDD7D974_FE9C_4BA3_BDD3_A1A3A23F8057”和“MyDllServicesModuleGac35Component.DDD3BAF7D974_AFEBC324” 这会破坏组件引用计数。D:\PROJECTS\MyDll.Experimental.3.0.0\Project\MyDll\MyDll.Wix.Services\MergeModule.wxs 34 1 MyDll.Wix.Services

安装程序应该能够检测到 .Net35 dll 安装到 GAC 的 C:\Windows\assembly,而 .Net40 dll 安装到 GAC 的 C:\Windows\Microsoft.NET\assembly。

重命名 DLL 不是一种选择。

谢谢!

更新

自然地,我在发布后就想出了一个解决方案,似乎将组件包装在其他元素中让我可以让它工作。后来我读了汤姆布洛杰特的帖子,所以这是正确的。

        <Directory Id="GAC1" Name="GAC">
            <Directory Id="GAC40" Name="GAC">
                <Component Id="MyDllServicesModuleGac40Component" Guid="307675AA-8AEC-473B-A78A-FB362CCEDE2A" Win64="yes">
                    <File Id="MyDllNet40DllGac" Name="MyDll.dll" KeyPath="yes" Assembly=".net" Source="..\MyDll\bin\Net40\MyDll.dll" />
                </Component>
            </Directory>
        </Directory>
        <Directory Id="GAC2">
            <Directory Id="GAC35" Name="GAC">
                <Component Id="MyDllServicesModuleGac35Component" Guid="FD74504A-6FE9-488E-9086-9DAD3024B35D" Win64="yes">
                    <File Id="MyDllNet35DllGac" Name="MyDll.dll" KeyPath="yes" Assembly=".net" Source="..\MyDll\bin\Net35\MyDll.dll" />
                </Component>
            </Directory>
        </Directory>

好吧,希望它对某人有所帮助!

4

1 回答 1

8

As explained by Aaron Stebner,

When you use the attribute Assembly=".net" for a file in WiX, it will create entries in the MsiAssembly and MsiAssemblyName table for this component and mark it as a GAC component. That means that the file will only be installed to the GAC by this component, and it will not install to the directory that the component is a child of. That directory will only be used by Windows Installer to stage a copy of that file when creating an administrative install point.

So the directories for your two components must be different since the file names are the same. If nothing else is targeted for those directories, they won't even be created. I put my GAC components under a subdirectory of my install folder:

<Directory Id="tmp_to_GAC" Name="tmp_to_GAC"> 

You'd need one for each GAC.

于 2013-06-13T17:17:17.420 回答