Copy PackageReferences to output directory
I have a netstandard2.1 classlib project, and I noticed that
PackageReference
s are not copied to the output directory.
I have tried Private="true"
and even CopyToOutputDirectory="always"
, but both had no effect.
Is there any way to configure msbuild to copy packages to the output directory?3 Replies
Update: chatgpt got a rare correct answer
setting
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
fixes the issueYep. The normal behaviour is that either your classlib project is being included in another solution, in which case the build tooling takes care of transitive dependencies, or it's being made into a nuget package, in which case your dependencies are declared in your nuspec and the project using yours is responsible for downloading them
In both cases, you might end up running against a slightly different version of your dependencies, depending on what the dependency resolution came up with
According to the doc page for CopyLocalLockFileAssemblies,
dotnet publish
should do the same thing for class libraries? Can't say I've ever tried thatdotnet publish
wouldn't work for me anyways