SZT
SZT

Reputation: 1966

How to make COMReference work in Azure CI/CD pipeline

I have used a dll to my project which gets added to my project file as a COMReference like following

<COMReference Include="GENERALCREDITREQUESTMANAGER450Lib">
  <Guid>{BDB6DDB5-5C02-492F-954E-68ED3D8F075D}</Guid>
  <VersionMajor>1</VersionMajor>
  <VersionMinor>0</VersionMinor>
  <Lcid>0</Lcid>
  <WrapperTool>tlbimp</WrapperTool>
  <Isolated>False</Isolated>
  <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>

Now the problem is it fails during my pipeline build, saying Namespace or type GENERALCREDITREQUESTMANAGER450Lib can't be found which is understandable because unlike other references it doesn't have any HintPath to locate the dll.

After looking around a bit I found this article that basically says use tlbImp to generate the dll and then reference that dll using the following syntax:

<Reference Include="GENERALCREDITREQUESTMANAGER450Lib">
  <HintPath>InteropAssemblies\GENERALCREDITREQUESTMANAGER450Lib.dll</HintPath>
  <EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>

But if I do that then my visual studio build fails, because then VS can't find the namespace even though it's added to the reference. One of the post suggested to use COMFileReference instead of COMReference but that ends up with same "Namespace not found" error.

How can I make the pipleline working?

Upvotes: 4

Views: 1210

Answers (1)

Martin Ullrich
Martin Ullrich

Reputation: 100581

The COMReference item requires the library to registered on the build server which may be hard to do depending on the environment.

The way to use tlbimp locally and add the generated .dll to the project sources is likely more compatible for your setup though it requires you to pass the namespace as a parameter (/namspace:GENERALCREDITREQUESTMANAGER450Lib) to achieve the same result as the COMReference.

Upvotes: 2

Related Questions