Search code examples
c#nuget

How to prevent NuGet assemblies from beeing copied


I have a solution with multiple projects, all of these projects have dependencies aligned but one project, for some reasons, needs a specific (old) version of the dependency.

What I did was to embed the old version as a resource and using the AssemblyResolver event.

The problem is that, when I build the solution, I do not want that the old dependency being copied to the bin folder because it is resolved in-memory, I want only the latest dependency.

I am using PackageReference for all of my projects, I need a way to tell when I do not want my dependency being copied to the bin folder.

Any idea? Thanks in advance.


Solution

  • As Marc suggested, adding to PackageReference

    <IncludeAssets>compile</IncludeAssets>
    <PrivateAssets>all</PrivateAssets>
    

    solved my problem.

    Thanks!