9

I have a library with a public COM/ActiveX interface built in Visual Studio 2012. I have an installer for this library written with WiX. It all works pretty well, except that on my build server we'd like to build the installer without admin privileges.

Here's the problem, currently I have "Register for COM interop" checked. This both generates a TLB file, and registers the library at build time (I think.) Registering at build time requires admin privileges, so the build will fail if I don't build with them.

However, if I uncheck "Register for COM interop" so I can build without admin privileges, the TLB file is not generated. So my WiX installer fails to build.

I can see two possible solutions for this:

  1. Have some way to generate the TLB without actually registering it at build time.
  2. Have WiX generate the TLB. I haven't seen anyway to do this. My current TLB install stuff references the TLB file directly, like this: xml <File Id="FILE.COM.TLB" KeyPath="yes" Source="..\..\Master\Proj\bin\$(var.Configuration)\Proj.tlb"> <TypeLib Id="{8CC87042-4B1B-4FE4-86D5-A12C1A55C8AA}" Description="PrimProj" HelpDirectory="DIR.BIN.HELP" Language="0" MajorVersion="1" MinorVersion="3"> .... <snip> .... </TypeLib> </File>
VividD
  • 10,456
  • 6
  • 64
  • 111
Jim
  • 651
  • 2
  • 7
  • 15

2 Answers2

4

The tlb will not be built if the COM interop cannot be registered. Registering the COM interop might fail due to missing administrator privileges, for example.

"TlbExp.exe" is the command to build the tlb file. To use it, uncheck the "Register for COM interop" option on the compile tab of the project properties, so the build will stop failing to register. Then, add this as a post build event, by clicking the "Build Events..." button located on the same tab:

"$(FrameworkSdkDir)\bin\NETFX 4.0 Tools\tlbexp.exe" "$(TargetFileName)" "$(TargetName).tlb"  
Michael Krebs
  • 1,212
  • 10
  • 11
0

Doesn't Heat harvest tlb files? Something like: heat file -out mytlb.wxs

I don't think that requires admin privilege.

Then you'd just install the tlb as a file and update the wxs to refer to its actual install location (the directory property) before you build the MSI file.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Sorry if that wasn't clear, that's what I am doing. That WiX code is what heat generated. The problem is, when building the installer, WiX still seems to require the source TLB file. The only way I know of to generate that TLB file is to use regasm or "Register for COM interop." THAT requires admin privileges. – Jim Jun 05 '14 at 17:04
  • Ok, sorry, for not catching that. The issue is that the Register for COM Interop setting generates entries directly onto the system and runs a registry harvester to get them, I think VS runs regasm behind your back. You need to just generate the TLB file, so tlbimp.exe is perhaps what you need since it generates the tlb without changing the system. – PhilDW Jun 05 '14 at 17:12
  • 3
    Turns out that tlbimp.exe does the opposite of what I want, but it did point me in the right direction. tlbexp.exe is the correct command. So this is now a post build event: "$(FrameworkSdkDir)\bin\NETFX 4.0 Tools\tlbexp.exe" Proj.dll Proj.tlb Also found this answer to the same question. Oops: http://stackoverflow.com/questions/3382142/building-an-com-interop-enabled-project-without-registering-it-during-build – Jim Jun 05 '14 at 19:18
  • 1
    I get the imp and exp confused sometimes :) – PhilDW Jun 06 '14 at 17:44