tags:

views:

191

answers:

3

I have a WiX installer which needs to install new bits for Interop.FOOBARLib.DLL to the GAC. The problem is that the version number is the same as the old version and the new bits do not get written the GAC on an upgrade. We execute the RemoveExistingProducts action after the InstallFinalize action.

We cannot move the RemoveExistingProducts action to earlier in the install.

The foobar.dll component is not my component so I cannot increment the type library version (which would cause the version of the interop to increment and all these problems go away).

Is there a way to FORCE the file to be upgraded in the GAC even if the version is the same? I want behavior similar to “gacutil.exe /f”.

The component looks like:

<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>
A: 

You could try to execute a custom action to delete the file, right before the components are installed. It's not recommended to use vbscript for custom actions but the example below should still illustrate the idea.

<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>
Wim Coenen
A: 

You can regenerate the interop assembly yourself and force it to get a higher version like this:

tlbimp /asmversion:1.2.3 /out:Interop.FOOBARLib.DLL foobar.dll
Wim Coenen
This is how I solved it. Also required the /sysarray param.
Mike
A: 

What you're trying to do is called an In-Place update of an Assembly in the GAC. For this to work correctly both Interop.FOOBARLib.dll libraries must have the same assembly version, but the newer dll must have a higher file version. The file version attribute must be included in the new MSI's MsiAssemblyName table. Wix does not include this attribute by default, so you have to add the following parameter to your .wixproj file:

<SetMsiAssemblyNameFileVersion>True</SetMsiAssemblyNameFileVersion>

See also:

In-place updating using Wix

Douglas M.

related questions