Convert a PCL to a regular Class Library
Asked Answered
M

2

21

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!

Mourning answered 20/11, 2013 at 11:0 Comment(3)
If the code is entirely compatible, why do you want to convert it? Just use the PCL as-is in your own project.Demodena
I use an old version of Xamarin which does not support PCL.Mourning
Is "recompile it for a different target" an option? Or are you trying to work at the dll level? If so: is it signed/strong-named?Boost
V
56

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" />
Vibrate answered 17/4, 2014 at 13:56 Comment(4)
You also need to remove all references to non pcl dll like System etc.Earful
I think that should be you need to add references to things like System and System.Core when going from PCL to normal. (which is what it sounds like the OP was asking) After the changes listed here, I had no references to anything, but it was easy enough to add them back. Thanks!Kutzer
Worked nicely. Thanks a lot.Archle
Also need to set correct targetFramework in packages.config and restore packages.Demoniac
A
6

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

Andie answered 28/10, 2014 at 8:59 Comment(1)
That's the opposite of what the author wanted to do. They already have a PCL and want to convert it to a regular class library. Also, the link is now broken.Valona

© 2022 - 2024 — McMap. All rights reserved.