Convert .NET Core 2.0 class libraries to .NET Standard

与世无争的帅哥 提交于 2019-11-30 04:11:46

In the project file, you can point target compilation to netstandard with the exact version.

Example of Proj.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
  </PropertyGroup>
</Project>
...

Microsoft provides good documentation about targeting types.

Dotnet Standard is not a framework or a library, it is an abstract set of instructions: what functionality should have System.Array, String, List, and so on. Currently, there are different implementations: .NET Framework, .NET Core, Mono, Xamarin, Windows Phone. It means that different implementations can recompile and reuse your library targeting netstandard. It is a very good choice for a NuGet package.

You can play with the versions and find the minimum function set required for your library. Each Dotnet Standard extends the functionality of the previous version. Thus, the less the targeted version is selected the more platforms your library will support.

You can edit the csproj file (can be done inside VS by right-clicking on the project file) and change

<TargetFramework>netcoreapp2.0</TargetFramework>

to

<TargetFramework>netstandard2.0</TargetFramework>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!