Del via


.NET Standard Library code sharing

.NET Standard libraries have a uniform API for all .NET Platforms including Xamarin and .NET Core. Create a single .NET Standard Library and use it from any runtime that supports the .NET Standard Platform. Refer to this chart for details of supported platforms.

While .NET Standard versions 1.0 through 1.6 provide incrementally larger subsets of the .NET Framework, .NET Standard 2.0 provides the best level of support for Xamarin applications and for porting existing Portable Class Libraries.

Visual Studio for Mac

This section walks through how to create and use a .NET Standard Library using Visual Studio for Mac.

Creating a .NET Standard Library

You can add a .NET Standard Library to your solution with these steps:

  1. In the Add New Project dialog, select the .NET Core category and then select .NET Standard Library:

    Create a .NET Standard library

  2. On the next screen, choose the target framework - .NET Standard 2.0 is recommended:

    Choose .NET Standard 2.0

  3. On the final screen, type the project name and click Create.

  4. The .NET Standard Library project will appear as shown in the Solution Explorer. The Dependencies node will indicate that the library uses the NETStandard.Library.

    Dependencies node in the solution indicates .NET Standard

Editing .NET Standard Library settings

The .NET Standard Library settings can be viewed and changed by right-clicking on the project and selecting Options as shown in this screenshot:

Edit .NET Standard target framework in Project Options

Inside you can change your version of netstandard by changing the Target Framework dropdown value.

Additionally: You can edit the .csproj directly to change this value.

.NET Standard and Xamarin.Forms for the .NET Developer (video)