Search code examples
nuget-packagenuget-spec

NuGet - choose references to add on install


I want to pack/publish a NuGet package. (private) using a .nuspec file :

\build
    \netstandard1.4
        \MyProject.dll
        \MyProject.Unmanaged.dll
    \net462
        \MyProject.dll
        \MyProject.Unmanaged.dll

In this package, I have a dll that I want to reference in my project, and another that I can't reference, but that is still required.

When I add the package to a project, the dll are automatically referenced, so I get an error : "Failed to add reference to 'MyProject.Unmanaged'. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

Is there a way to choose which dll must be automatically referenced or not ?


Solution

  • See the chapter "Explicit assembly references" : https://learn.microsoft.com/en-us/nuget/schema/nuspec