Visual Studio: Converting a Class Library to Portable Class Library

Before you even start asking GOOGLE about how to convert a Class Library Project to Portable Class Library (PCL) in Visual Studio, why don’t you try to do it by yourself?

In fact that is the best approach for this scenario because if you try to google for the solution, you will realize that none of the suggested answers actually agree.

@ StackOverflow:

@GeeksWithBlogs

The main reason the solutions provided do not work is that because of the difference in Visual Studio versions. The solutions vary by Visual Studio version: 2012, 2013, 2015 and now 2017.

Solution

As I said before, this will require some manual work from your side.

You will have to manually compare the differences between regular Class Library project and a Portable Class Library project.

To do this comparison, first create a new PCL project (no you do not have to move all of your class libraries to PCL project).

Once we have  a sample PCL project, we can compare the .csproj file of this project with the class library project’s .csproj file.

So, basically just add/remove the lines that are not available in you class library project from your portable class library project.

Once you have made necessary adjustments, Visual Studio will recognize the Class Library project as a Portable Class Library.

With this approach, you can also convert a Portable Class Library project back to Class Library project as well.

Good luck!

 

Tags: