Tim Long
Tim Long

Reputation: 13788

Wix !(bind.AssemblyFullName.fileId) only works on GACed assemblies?

Woe, woe and thrice woe. Why does Wix make installing .NET assemblies SOOOOOO difficult!

I'm installing a COM Inprocess Server which is implemented in .NET, in my Wix install I need to create the registry entries for it. I don't WANT to do this, I'd rather Wix had an equivalent of RegAsm, but they make me do this manually. I got tired of getting flamed for suggesting this was a tad arcane, so I gave up and tried to do it the declarative way, like a good boy. So, here's what my registry stuff looks like now:

<File Id="filDriverAssembly" Source="$(var.TiGra.Astronomy.AWRDriveSystem.TargetPath)" KeyPath="yes" Vital="yes" Assembly=".net">
  <!--<Class Context="InprocServer32" Description="$(var.InstallName)" Id ="$(var.DriverGuid)" ThreadingModel ="both" >
    <ProgId Description="$(var.InstallName)" Id ="$(var.DriverId)" />
  </Class>-->
</File>
<RegistryKey Root="HKCR" Key="$(var.DriverId)"  Action="createAndRemoveOnUninstall">
  <RegistryValue Type="string" Value="$(var.DriverTypeName)"/>
  <RegistryKey Key="CLSID">
    <RegistryValue Type="string" Value="$(var.DriverGuid)" />
    <RegistryKey Key="$(var.DriverGuid)">
      <RegistryValue Type="string" Value="$(var.DriverTypeName)"/>
      <RegistryKey Key="InprocServer32">
        <RegistryValue Type="string" Value="mscoree.dll" />
        <RegistryValue Type="string" Name="ThreadingModel" Value="Both"/>
        <RegistryValue Type="string" Name="Class" Value="$(var.DriverTypeName)"/>
        <RegistryValue Type="string" Name="Assembly" Value="!(bind.AssemblyFullName.filDriverAssembly)"/>
        <RegistryValue Type="string" Name="RuntimeVersion" Value="2.0.50727"/>
        <RegistryValue Type="string" Name="CodeBase" Value="file:///[#filDriverAssembly]" />
        <RegistryKey Key="!(bind.fileVersion.filDriverAssembly)" >
          <RegistryValue Type="string" Name="Class" Value="$(var.DriverTypeName)"/>
          <RegistryValue Type="string" Name="Assembly" Value="!(bind.AssemblyFullName.filDriverAssembly)"/>
          <RegistryValue Type="string" Name="RuntimeVersion" Value="2.0.50727"/>
          <RegistryValue Type="string" Name="CodeBase" Value="file:///[#filDriverAssembly]" />
        </RegistryKey>
      </RegistryKey>
      <RegistryKey Key="ProgId">
        <RegistryValue Type="string" Value="$(var.DriverId)" />
      </RegistryKey>
      <RegistryKey Key="Implemented Categories">
        <RegistryKey Key="{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" />
      </RegistryKey>
    </RegistryKey>
  </RegistryKey>
</RegistryKey>
<!-- Wow6432Node for x86 compatibility, installed only on x64 systems -->
<!-- HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node -->
<?if $(var.Win64) = "yes" ?>
<RegistryKey Root="HKCR" Key="Wow6432Node" Action="createAndRemoveOnUninstall">
  <RegistryKey Key="CLSID">
    <RegistryValue Type="string" Value="$(var.DriverGuid)" />
    <RegistryKey Key="$(var.DriverGuid)">
      <RegistryValue Type="string" Value="$(var.DriverTypeName)"/>
      <RegistryKey Key="InprocServer32">
        <RegistryValue Type="string" Value="mscoree.dll" />
        <RegistryValue Type="string" Name="ThreadingModel" Value="Both"/>
        <RegistryValue Type="string" Name="Class" Value="$(var.DriverTypeName)"/>
        <RegistryValue Type="string" Name="Assembly" Value="!(bind.AssemblyFullName.filDriverAssembly)"/>
        <RegistryValue Type="string" Name="RuntimeVersion" Value="2.0.50727"/>
        <RegistryValue Type="string" Name="CodeBase" Value="file:///[#filDriverAssembly]" />
        <RegistryKey Key="!(bind.assemblyVersion.filDriverAssembly)" >
          <RegistryValue Type="string" Name="Class" Value="$(var.DriverTypeName)"/>
          <RegistryValue Type="string" Name="Assembly" Value="!(bind.AssemblyFullName.filDriverAssembly)"/>
          <RegistryValue Type="string" Name="RuntimeVersion" Value="2.0.50727"/>
          <RegistryValue Type="string" Name="CodeBase" Value="file:///[#filDriverAssembly]" />
        </RegistryKey>
      </RegistryKey>
      <RegistryKey Key="ProgId">
        <RegistryValue Type="string" Value="$(var.DriverId)" />
      </RegistryKey>
      <RegistryKey Key="Implemented Categories">
        <RegistryKey Key="{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" />
      </RegistryKey>
    </RegistryKey>
  </RegistryKey>
</RegistryKey>
<?endif ?>

RegAsm is for wimps, eh? Anyway, notice that I need to get the assembly full name to create some of the registry keys. I'm using binder variables, specifically, Value="!(bind.AssemblyFullName.filDriverAssembly)".

This however, does not work unless I add the attribute Assembly=".net" to the file entry. If I don't add that attribute, or if I use Assembly="no", then I get

Error 2 Unresolved bind-time variable !(bind.AssemblyFullName.filDriverAssembly).

When I add Assembly=".net" to the file item, then the binder variables work just fine, but Wix puts my assembly into the Global Assembly Cache, which is NOT what I want! Oh, man.

Is it not possible to query an assembly's full name in a Wix project if its not going into the GAC? Why do these two things depend on each other?

Upvotes: 6

Views: 1873

Answers (1)

Bob Arnson
Bob Arnson

Reputation: 21886

Unless a file is marked as an assembly, it's just like any other file; WiX has no idea it might have assembly attributes. Check out the AssemblyApplication attribute: You can set it to an appropriate file and set @Assembly=".net" without telling MSI the file goes into the GAC.

Upvotes: 7

Related Questions