Search code examples
c#visual-studionugetnuget-packagepackagereference

NuGet Package references copies dll local


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?


Solution

  • You can use PrivateAssets. Copied from the docs

    <ItemGroup>
        <!-- ... -->
    
        <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0">
            <PrivateAssets>all</PrivateAssets>
            <ExcludeAssets>runtime</ExcludeAssets>
        </PackageReference>
    
        <!-- ... -->
    </ItemGroup>