NuGet Package references copies dll local

Andrey Lukoprov picture Andrey Lukoprov · Mar 11, 2019 · Viewed 9.3k times · Source

I have some requirement to set Copy Local to false for the NuGet dll. Before that, I used the package.config format and everything worked fine. After migration to Package Reference format, I cannot find a way how to do that. Could someone help me?

Answer

zivkan picture zivkan · Mar 11, 2019

You can use PrivateAssets. Copied from the docs

<ItemGroup>
    <!-- ... -->

    <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0">
        <PrivateAssets>all</PrivateAssets>
    </PackageReference>

    <!-- ... -->
</ItemGroup>

edit: actually, you might need to use <ExcludeAssets>runtime</ExcludeAssets>.