【问题标题】:Force installer to upgrade a file in the GAC regardless of the version number无论版本号如何,强制安装程序升级 GAC 中的文件
【发布时间】:2009-11-25 15:54:38
【问题描述】:

我有一个 WiX 安装程序,它需要将 Interop.FOOBARLib.DLL 的新位安装到 GAC。问题是版本号与旧版本相同,并且新位不会在升级时写入 GAC。我们在 InstallFinalize 操作之后执行 RemoveExistingProducts 操作。

我们无法将 RemoveExistingProducts 操作移到安装的早期。

foobar.dll 组件不是我的组件,因此我无法增加类型库版本(这会导致互操作版本增加,所有这些问题都会消失)。

即使版本相同,有没有办法在 GAC 中强制升级文件?我想要类似于“gacutil.exe /f”的行为。

组件看起来像:

<Component Id="Interop.FOOBARLib.dll" Guid="{4E0C173E-34DF-4249-A3A6-5530047FA65B}" >
    <File Id="Interop. FOOBARLib.dll" Name="Interop.FOOBARLib.dll" KeyPath="yes" Assembly=".net"/>
</Component>

【问题讨论】:

    标签: wix windows-installer


    【解决方案1】:

    您尝试执行的操作称为 GAC 中程序集的就地更新。为使其正常工作,两个 Interop.FOOBARLib.dll 库必须具有相同的程序集版本,但较新的 dll 必须具有更高的文件版本。文件版本属性必须包含在新 MSI 的 MsiAssemblyName 表中。 Wix 默认不包含此属性,因此您必须在 .wixproj 文件中添加以下参数:

    <SetMsiAssemblyNameFileVersion>True</SetMsiAssemblyNameFileVersion>
    

    另见:

    In-place updating using Wix

    【讨论】:

      【解决方案2】:

      您可以自己重新生成互操作程序集并强制它获得更高版本,如下所示:

      tlbimp /asmversion:1.2.3 /out:Interop.FOOBARLib.DLL foobar.dll 
      

      【讨论】:

        【解决方案3】:

        您可以在安装组件之前尝试执行自定义操作来删除文件。是not recommended to use vbscript for custom actions,但下面的示例仍然可以说明这个想法。

        <CustomAction Id="ForceRemove" Script="vbscript" Execute="deferred">
          <![CDATA[
          Dim fso
          Set fso = CreateObject("Scripting.FileSystemObject")
          fso.DeleteFile("c:\somefile.dll")
          ]]>
        </CustomAction>
        
        <InstallExecuteSequence>
           <Custom Action='ForceRemove' Before='InstallFiles'/>
        </InstallExecuteSequence>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-06-30
          • 1970-01-01
          相关资源
          最近更新 更多