Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to include a referenced assembly in a NuGet package? [duplicate]

$
0
0

I'm having trouble getting dotnet pack to include a referenced Interop assembly in my package.

Here's the relevant project markup:

<PropertyGroup><TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks></PropertyGroup><ItemGroup><Reference Include="Interop.QBFC16Lib"><HintPath>lib\Interop.QBFC16Lib.dll</HintPath></Reference><None Update="lib\Interop.QBFC16Lib.dll"><PackagePath Condition="'$(TargetFramework)' == 'net8.0'">lib\net8.0\</PackagePath><PackagePath Condition="'$(TargetFramework)' == 'netstandard2.0'">lib\netstandard2.0\</PackagePath><CopyToOutputDirectory>Always</CopyToOutputDirectory><Private>true</Private><Pack>true</Pack></None></ItemGroup>

My TFS (yes, TFS—I'm a holdout on the old name) build pipeline is correctly adding the built assembly to the package, but Interop.QBFC16Lib.dll is being excluded.

I did find this answer, and the linked NuGet package, but those seem to be addressing a requirement to add a complete project reference to the package, not just a single .dll.

Then there're these:

...but they allude to the use of a .nuspec file. I'm constrained against using one, as my pipeline contains a script that modifies package-related properties in the project file (description, author, etc.). I'm concerned that if I introduce a .nuspec it'll negate the work of my carefully-formulated script.

The pipeline build and tests succeed, so I'm confident that the basic structures are OK.

I tried adding this, but still I had no luck:

<Target Name="EnsureInteropDllIncluded" BeforeTargets="Pack"><ItemGroup><IncludeInteropDll Include="lib\Interop.QBFC16Lib.dll" /></ItemGroup><Copy SourceFiles="@(IncludeInteropDll)"        DestinationFolder="$(OutputPath)lib\net8.0\"        SkipUnchangedFiles="false" /><Copy SourceFiles="@(IncludeInteropDll)"        DestinationFolder="$(OutputPath)lib\netstandard2.0\"        SkipUnchangedFiles="false" /></Target>

Then there's this answer, but that approach only adds a link to the consuming project that points to the assembly's location in my local package cache on my dev machine. Clearly that won't work, as the assembly must be deployed together with the package.

Further, no reference to the assembly is added to the consuming project. I'm going to need that as well.

As a last gasp I also tried these, but to no avail:

<None Update="lib\Interop.QBFC16Lib.dll" /><None Include="lib\Interop.QBFC16Lib.dll" /><!-- (vs. Reference Update as above) -->

How can I get dotnet pack to include Interop.QBFC16Lib.dll in my package in a way that results in both the assembly and a reference to it being added to the consuming project? And without using a .nuspec file?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>