C
C#5h ago
Ruttie

Copy PackageReferences to output directory

I have a netstandard2.1 classlib project, and I noticed that PackageReferences 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
Ruttie
RuttieOP4h ago
Update: chatgpt got a rare correct answer setting <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> fixes the issue
canton7
canton74h ago
Yep. 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 that
Ruttie
RuttieOP4h ago
dotnet publish wouldn't work for me anyways

Did you find this page helpful?