1

I am working on a project where I need to handle version downgrades of System.IO.Compression.Native.dll in an MSI installer. This issue was discussed on GitHub, where it was suggested to use the CompanionFile feature of WiX to resolve version conflicts.

GitHub Issue for Reference:

Version downgrade in .NET 7 for System.IO.Compression.Native.dll leads to broken Microsoft Installers #82518

Steps to Reproduce:

  1. Create a new .NET 6 application.
  2. Publish the app as a self-contained application.
  3. Bundle the application as an MSI file using the WiX toolset.
  4. Repeat steps 1-3 for .NET 7.
  5. Upgrade the MSI from .NET 6 to .NET 7, leading to the missing System.IO.Compression.Native.dll issue.

Workaround:

The suggested workaround is to use the CompanionFile feature of WiX. Specifically, to configure System.IO.Compression.dll to be the companion to System.IO.Compression.Native.dll.

Problem:

I understand that I need to set the CompanionFile attribute, but I am using the harvesting feature of WiX, which automatically generates the component and file XML elements. As a result, I am unable to directly edit these elements to add the CompanionFile attribute.

Questions:

  1. How can I configure the CompanionFile attribute for files that are automatically harvested in a .wixproj file?
  2. Is there a way to modify or extend the harvested output to include the necessary CompanionFile attribute?

References:

Any help or guidance on how to handle this situation would be greatly appreciated!

Based on the discussion, I know the configuration should look something like this if I could edit the XML directly:

<Component Id="Comp_Compression" Guid="*">
  <File Id="System_IO_Compression_dll" Source="@(Path to System.IO.Compression.dll)" KeyPath="yes" />
  <File Id="System_IO_Compression_Native_dll" Source="@(Path to System.IO.Compression.Native.dll)" CompanionFile="System_IO_Compression_dll" />
</Component>

However, I need to achieve this configuration while using the harvesting feature.

1 Answer 1

0

I faced exactly the same issue, and here is the solution:

  1. Use the companion files, as you described.

  2. For harvesting, use a XSLT transformation file.

    Note: If you are using heat.exe, then pass the -t argument with file.xslt or, in WIX4, you can define it in the project file)

  3. In the transformation file, write something like this:

    <xsl:key
              name="SystemIOCompressionNativeCompanionFile"
              match="wix:Component[ contains(wix:File/@Source, 'System.IO.Compression.Native.dll') ]"
              use="@Id"
      />
      <xsl:key
              name="SystemIOCompressionNativeCompanionFileParent"
              match="wix:Component[ contains(wix:File/@Source, 'System.IO.Compression.dll') ]"
              use="@Id"
      />
    

    This inlcudes everything:

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

    Except:

    <xsl:template match="*[ self::wix:Component or self::wix:ComponentRef ][ key( 'SystemIOCompressionNativeCompanionFile', @Id ) ]" />
    
      <xsl:template match="*[ self::wix:Component or self::wix:ComponentRef ][ key( 'SystemIOCompressionNativeCompanionFileParent', @Id ) ]" />
    
Sign up to request clarification or add additional context in comments.

1 Comment

Do you have a complete sample with a project? I'm using wix5 and unable to put this to work. Also using the new <Files Include="$(var.HarvestPath)**"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.