For example, here's my .csproj right now:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net451</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="NETStandard.Library" Version="1.6.1" />
</ItemGroup>
</Project>
Nothing from Dapper will be exposed in the public API, so it seems like I should keep it as a private implementation detail. But when creating a test .nupkg and referencing it from a .NET Framework Console App, the app gains a reference to Dapper.
Try setting the PrivateAssets
flag:
<PackageReference Include="Dapper">
<Version>1.50.2</Version>
<PrivateAssets>Runtime</PrivateAssets>
</PackageReference>
From the docs (which could probably use some clarification):
... these can include any of the following values:
- Compile – are the contents of the lib folder available to compile against
- Runtime – are the contents of the runtime folder distributed
- ContentFiles – are the contents of the contentfiles folder used
- Build – do the props/targets in the build folder get used
- Native - are the contents from native assets copied to the output folder for runtime
- Analyzers – do the analyzers get used
Or, instead:
- None – none of those things get used
- All – all of those things get used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.