Search code examples
commsbuildbuild-server

How to build a project that relies on a third party COM library on a build server?


I have a project that I am developing that uses a third party COM library as a reference and I would like to build this project on a Visual Studio Team Services build client. My first idea is to create a MSBuild task that checks to see if the COM library is installed on the local computer and if it is not, go ahead and install it, but this seems like a really messy way to do this. I have searched around but it seems as though all the answers date back years and I can't seem to make the few I have found work in a VS 2013 project. How have other people solved this problem? Is there a cleaner way?

For reference I have also tried this solution, which looks really clean, to no avail.


Solution

  • I would go one of these routes:

    • Generate interop dll with tlbimp, add it to your project and reference it directly:
      • In VS command prompt, execute tlbimp.exe <your_dll> to generate the interop dll. You can specify the name with /out option.
      • put this dll somewhere with your code
      • reference it by going to Add reference > Browse and click Browse... to add the dll
    • Generate the tlb from COM dll , add it to the project and reference the tlb:
      • Generate the tlb (e.g. using OLE/COM Object viewer) or extract it from the dll resources,
      • put this tlb somewhere with your code
      • reference it by going to Add reference > COM and click Browse... to add the tlb reference to project
      • As @HansPassant noted in comments, this solution still relies on registry, but you can register it with regtlb, regtlib or similar tool, as a prebuild step, which should be easier than installing the server (though if it is just a dll, you could use regsvr32 to register it instead of full install). However, this is still more complex than the approach with interop dll