Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a PCL to a regular Class Library

Tags:

I currently have a Portable Class Library whose code is entirely compatible with a regular Class Library without any modification.

I was wondering if there was an existing software to do the conversion automatically ; I looked into the Visual Studio tools but could not find any suitable. Before writing my own I just wanted to be sure!

like image 913
Max Avatar asked Nov 20 '13 11:11

Max


People also ask

What is the difference between .NET Standard and PCL portable class libraries )?

NET Standard is platform-agnostic, it can run anywhere, on Windows, Mac, Linux and so on. PCLs can also run cross-platform, but they have a more limited reach. PCLs can only target a limited set of platforms.

How do you create a class library in Visual Basic?

Right-click on the solution in Solution Explorer and select Add > New Project. On the Add a new project page, enter library in the search box. Choose C# or Visual Basic from the Language list, and then choose All platforms from the Platform list. Choose the Class Library template, and then choose Next.

What is portable class library in C#?

The Portable Class Library project enables you to write and build managed assemblies that work on more than one . NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects.


2 Answers

The differences will be in your .proj file.

Having tried it myself you will have to do all of the following;

  1. Remove the <TargetFrameworkProfile> element
  2. Remove the <ProjectTypeGuids> element
  3. Change where you have #2 (below) for what I shown in #1

1. Regular class library

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 

2. Portable class library

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> 
like image 135
obaylis Avatar answered Dec 28 '22 15:12

obaylis


Use VSCommands, it has as a build in functionality to convert Projects to PCL. Right mouse click on Project and convert. It´s free and part of Visual Studio extensions http://vscommands.squaredinfinity.com/Features-SolutionExplorer

Update 2016-10-12: Above link is dead. The tool has been rewritten for Visual Studio 2015 and can be found here: https://visualstudiogallery.msdn.microsoft.com/c84be782-b1f1-4f6b-85bb-945ebc852aa1

like image 40
Martin Avatar answered Dec 28 '22 15:12

Martin