Pinco Pallino
Pinco Pallino

Reputation: 1016

How to migrate a .NET PCL Project to .NET Standard 2.0

I have a solution with PCL and .NET Core 1.0 projects. Once updated to VS 2017 15.3, when I navigate to the project properties I have a "Application" page for .NET Core 1.0 Projects where I can change from 1.0 to 2.0. Unfortunately the PCL projects only shows the standard "Library" page with an extra "Learn More" link that navigates me to a ".NET Standard" web page but no option to migrate to .NET Standard 2.0. All the rest is the same and it only allows me to change the usual Targets. No reference to anything else related to .NET Standard.

Do I have to recreate the projects as .NET Standard 2.0 myself?

Upvotes: 2

Views: 565

Answers (1)

M.Hassan
M.Hassan

Reputation: 11032

For pcl:

  • Create .Net Standard library project

  • Modify the csproj file manually to Multi Target:

    Suppose that your pcl is: portable-net45+win8+wpa81+wp8

     <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
         <TargetFrameworks>netstandard2.0;portable-net45+win8+wpa81+wp8</TargetFrameworks>
       </PropertyGroup>
    

    note TargetFrameworks by s not TargetFramework

  • Copy past your source

  • Install nuget packages, or reference them manually in csproj, example:

    <ItemGroup>
       <PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
    </ItemGroup>
    
  • It's supposed that pcl is compiled without errors, in netstandrd2 you may find errors, modify your source as needed.

  • Modify Unit test projects and be sure that you passed all tests in both environment.

Upvotes: 1

Related Questions