Reputation: 4850
I am having trouble getting a nuget package to correctly add a COM interop DLL to my project. The nuget documentation (especially the section on COM interops) is a little unclear, so I hope someone can fill in the gaps.
I'm using Visual Studio 2017 Enterprise.
Here is my nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>MyInteropLibs</id>
<version>1.0.1</version>
<title>Does stuff</title>
<authors>me</authors>
<description>My COM Interop DLL</description>
<summary>ditto</summary>
<copyright>me</copyright>
</metadata>
<files>
<file src="..\AxVCF150.DLL" target="lib" />
<file src="..\VCF150.DLL" target="build" /> <!--the interop-->
<file src="VCF150Interop.targets"/>
</files>
</package>
and here is my accompanying Targets file (VCF150Interop.targets) :
<Target Name="Unique.VCF150" AfterTargets="ResolveReferences" BeforeTargets="FindReferenceAssembliesForReferences">
<PropertyGroup>
<InteropAssemblyName>VCF150</InteropAssemblyName>
</PropertyGroup>
<ItemGroup>
<ReferencePath Condition=" '%(FileName)' == '{InteropAssemblyName}' AND '%(ReferencePath.NuGetPackageId)' == '$(MSBuildThisFileName)' ">
<EmbedInteropTypes>false</EmbedInteropTypes>
</ReferencePath>
</ItemGroup>
</Target>
As far as I can tell this is exactly what the documentation prescribes, and the built package when inspected seems to have the right files in the right places in the package. However when I install it in the project using the nuget package manager, only AxVCF150.dll is added as a reference and the interop dll is completely ignored.
What am I missing?
Upvotes: 1
Views: 374
Reputation: 363
It may sound absurd. Have you tried changing the name of the dll target? for example: VCF150.DLL to interop.VCF150.DLL
<files>
<file src="..\AxVCF150.DLL" target="lib" />
<file src="..\VCF150.DLL" target="interop.VCF150.DLL" /> <!--the interop-->
</files>
Upvotes: 1