Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (39 sloc) 1.81 KB
published title date author layout permalink tags
true
Update Portable Class Library project to .NET Standard
2019-02-23 09:45:11 UTC
fabiocozzolino
post
/update-portable-class-library-project-to-.net-standard/
.NET
.NET Standard
.NET Core

Recently, I decided to upgrade my TitiusLabs.Xamarin library to the latest version of Xamarin.Forms and to .NET Standard 2.0. Here a small guide you need to follow if you want to upgrade your project from a very old version.

Update your project to .NET Standard 2.0

The first step in my path is the update of the TitiusLabs.Core project, a Portable Class Library (PCL) project, to a .NET Standard Library. To proceed, you need to be sure to have the right .NET Core version installed so, if not, go to the download page and install it!

Now, simply open the .csproj file and full replace it with the following xml:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
</Project>

Check your solution

Reopen your solution, or refresh it, and check if all projects correcly loads and reference your .NET Standard project. Most probably, you'll get the following errors:

.NET Standard errors

If you want to still use AssemblyInfo.cs, then add the following xml element into the .csproj:

<PropertyGroup>
   <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup> 

Now your code will work fine. To choose the correct version, be sure to check .NET Standard compatibility on this page.

That's all!

You can’t perform that action at this time.