When creating a library of .NET standard classes in VS 2017 RC, how should I save package references as private implementation details?

For example, here is 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 of Dapper will be revealed in the public API, so it seems to me that I should store it as a private implementation. But when you create a .nupkg test and a link to it from a .NET Framework Console application, the application gets a link to Dapper.

+4
source share
1 answer

Try setting the flag PrivateAssets:

<PackageReference Include="Dapper">
  <Version>1.50.2</Version>
  <PrivateAssets>Runtime</PrivateAssets>
</PackageReference>

From the docs (which could probably use some clarification):

... they may include any of the following values:

  • - lib,
  • - .
  • ContentFiles - .
  • - /
  • Native - , .
  • -

:

  • -
  • - .
+3

Source: https://habr.com/ru/post/1667827/


All Articles