0

I am trying to recreate the functionality of a legacy installer using WixSharp. In the legacy Setup Project, some of the third party DLL's were marked "vsdrfCOMSelfReg". I have seen in various places that you can add to the File tag SelfRegCost="0" but it is highly frowned upon.

How can I properly register a COM DLL using WixSharp? Is there a way to just add SelfRegCost field to the File tag for the DLL from WixSharp?

Community
  • 1
  • 1
TaRDy
  • 999
  • 1
  • 8
  • 21

2 Answers2

2

It's true that you can say something like SelfRegCost=1 in the File element, but every install guy will tell you it's evil, as you discovered. The non-evil way is to use heat.exe on the Dll to extract the registration data into a wxs file. If necessary add interface entries for type library data by running heat.exe on a tlb file. Heat is just a WiX tool, I don't see how WiXSharp is involved.

The point is that registration data is static and can be stored in the MSI via WiX and simply written to the system at install time without requiring the Dll to be loaded and called.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • 2
    I would like to know if I can do everything from WixSharp so that other developers on the project don't have to know about heat or the underlying Wix tools and only need to be able to work with a C#-like syntax of WixSharp to add anything new to the setup. – TaRDy Aug 26 '14 at 13:14
1

After some further source browsing and experimentation, I figured out how to force the evil approach through WixSharp. I also later discovered that this was somewhat covered by the WixSharp Sample "CustomAttributes".

"Evil Way"

File LibToReg = new File("..\Path\To\LibToReg.dll");
LibToReg.AttributesDefinition += "SelfRegCost=1";

Alternatively (based on the CustomAttributes sample):

File LibToReg = new File("..\Path\To\LibToReg.dll")
            {
                Attributes = new Attributes() { { "SelfRegCost", "1" } }
            };

This will generate the following wxs underneath:

<Component Id="Component.LibToReg.dll" Guid="EABD7A49-26DD-4720-AE5A-AA9EEFD8C91A">
          <File Id="File.LibToReg.dll" Source="..\Path\To\LibToReg.dll" SelfRegCost="1" />
</Component>

The rest of the generated code looks the same as any other DLL that is installed.

For reference, here is the original wxs source that was generated from the original Setup Project using "VDProj to WiX Converter" from Add-In Express. I believe the SelfRegCost="0" was added by the converter, but a co-worker may have manually added it in afterwards.

<Component Id='com_FB7105EC_5352_4561_AE01_405562F0EA1E' Guid='6718170E-0335-4FD6-A1E8-D9E926DDE3EC' Permanent='no' SharedDllRefCount='no' Transitive='no'>
            <File Id='_FB7105EC_5352_4561_AE01_405562F0EA1E' DiskId='1' Hidden='no' ReadOnly='no' SelfRegCost='0' System='no' Vital='yes' Compressed='yes' Name='LibToReg.dll' Source='..\Path\To\LibToReg.dll' KeyPath='yes' />
</Component>
TaRDy
  • 999
  • 1
  • 8
  • 21
  • 1
    I wound up using this same attributes approach to mark parts of an installer as 64-bit, to ensure registry entries were applied to the 64-bit registry. I was able to use a slightly simpler syntax, which would probably be interchangeable with what you used. It was: `{ AttributesDefinition = "Component:Win64=yes" },` so this might also work for yours `{ AttributesDefinition = "Component:SelfRegCost=1" }` not necessarily better, just different. – Developer63 Dec 18 '14 at 03:34