WIX 将两个程序集部署到 GAC [英] WIX deploy two assemblies to GAC
问题描述
使用 WIX,并尝试安装两个相同的程序集,一个用于 .Net35,另一个用于 .Net40.我使用了两个单独的组件,但是 WIX 阻止了项目的编译.
Using WIX, and trying to install two of the same assemblies, one for .Net35 and the other .Net40. I am using two separate components, however WIX is preventing the project from compiling.
<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: 'MyDllServicesModuleGac40Component.DDD7D974_FE9C_4BA3_BDD3_A1A3A23F8057' 和 'MyDllServicesModuleGac35Component.DDD7D974_FE9C_4BA3_BDD3_A1A3A23F8057':目标文件 'MYDLL.DLL' 由SFN系统上的两个不同的组件安装在 '[TARGETDIR] \ GAC \'.这会破坏组件引用计数.D:\PROJECTS\MyDll.Experimental.3.0.0\Project\MyDll\MyDll.Wix.Services\MergeModule.wxs 34 1 MyDll.Wix.Services
Error 29 ICE30: The target file 'MyDll.dll' is installed in '[TARGETDIR]\GAC\' by two different components on an SFN system: 'MyDllServicesModuleGac40Component.DDD7D974_FE9C_4BA3_BDD3_A1A3A23F8057' and 'MyDllServicesModuleGac35Component.DDD7D974_FE9C_4BA3_BDD3_A1A3A23F8057'. This breaks component reference counting. 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.
The installer should be able to detect that the .Net35 dll gets installed to the GAC at C:\Windows\assembly, while the .Net40 dll gets installed to the GAC at C:\Windows\Microsoft.NET\assembly.
重命名 DLL 不是一种选择.
Renaming the DLLs is not an option.
谢谢!
更新
自然地,我在发布后就想出了一个解决方案,似乎将组件包装在其他元素中使我能够使其工作.后来我读了 Tom Blodget 的帖子,所以这是正确的.
Naturally I came up with a solution just after posting, seem wrapping the components in additional elements allowed me to get this to work. Later I read Tom Blodget's post so that is correct.
<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>
好吧,希望它对某人有所帮助!
Well, hope it helps someone!
推荐答案
如 亚伦·斯特布纳、
当您在 WiX 中为文件使用属性 Assembly=".net" 时,它将为此在 MsiAssembly 和 MsiAssemblyName 表中创建条目组件并将其标记为 GAC 组件.这意味着文件只会被这个组件安装到 GAC,它不会安装到组件是其子目录的目录.那目录将仅由 Windows 安装程序用于暂存创建管理安装点时使用该文件.
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.
因此,您的两个组件的目录必须不同,因为文件名相同.如果没有其他针对这些目录的目标,它们甚至不会被创建.我将 GAC 组件放在安装文件夹的子目录下:
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">
每个 GAC 都需要一个.
You'd need one for each GAC.
这篇关于WIX 将两个程序集部署到 GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!