tags:

views:

35

answers:

1

I have a Wix 3.0 project that installs some .Net assemblies into an existing application. As part of the installation, I need to update the application's config file with bindingRedirects so that the correct assembly versions are used, e.g.,

<configuration>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="MyAssembly" publicKeyToken="deadbeefdeadbeef" culture="neutral" />
            <bindingRedirect oldVersion="1.0.0.0-1.0.10.0" newVersion="1.0.10.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

This will redirect bindings to MyAssembly versions up to 1.0.10.0 so that they go to the installed version 1.0.10.0. The installed version number (newVersion) changes over time, and so has to be determined at install time.

Cheers.

+1  A: 

You can use the XmlFile element to update an XML file during a WiX install.

However, be sure to include the config file in the same component as the exe file (as a companion file); otherwise, there may be problems during upgrading.

Stephen Cleary
Thanks, but I also need to find the assembly information (name, publicKeyToken, version number) at install time. The version number in particular will vary.
ShellShock
I suggest you first ask yourself if you really want to do this. The whole point of a binding redirect is to allow *compatible* versions to be loaded - if you just have a binding redirect to "whatever" version is on the computer, then sooner or later (when the DLL is no longer backwards-compatible) your program will simply fail.
Stephen Cleary