Reputation: 2418
Say, I have created and extended a Windows Phone Class Library (WPCL) project or any other Class Library project that targets a specific platform.
Say, I am now considering targeting another .NET platform, e.g., Windows Store, but at the time of creating my Class Library I chose to create a platform specific Class Library (such as my WPCL) and not a Portable Class Library (PCL).
The source code written is portable, it just requires a PCL project file (csproj).
From WPCL and PCL csproj comparison it seems that only a couple of properties differ. But do I need to hack the csproj to get the work done?
Basically, I want to know whether,
is there a way, to automatically convert a platform-specific Class Library into a Portable Class Library without hacking csproj files?
Upvotes: 2
Views: 1625
Reputation: 366
You can use following Visual Studio Extension to do this automatically.
After install choose "Tools > Convert projects to PCL" and select projects you want to convert.
Upvotes: 1
Reputation: 11
I know you are asking for a non-hacking way, but as it is quite simple I post the solution anyway: http://geekswithblogs.net/imilovanovic/archive/2012/08/31/vs2012---how-to-manually-convert-.net-class-library-to.aspx
This works quite fine, but it doesn't seem to work perfectly for VS2013 anymore (It doesn't show you the change target dialog but only a dropdown box with all possible combinations). I played around a little bit and worked out how I can change a csproj to a portable library targeting Windows 8.1. I don't know if there are any side effects (and to be honest, I don't know exactly what I'm doing), but at least I can see no difference between my converted and the original portable libs and everything compiles fine.
replace the import statement (normally at the end of the document) with the following:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
add the following tags to the first property group
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
and finally remove the TargetFrameworkTag.
The project should now be a portable lib referencing Windows 8.1 - just change it to whatever you like now.
Note: I did not try, but I guess this only works for VS2013 (for 2012 use the link above).
Upvotes: 1
Reputation: 16744
No, there's not currently a way to do this. If your code is entirely portable I'd suggest switching to a PCL. I think he best way to do this is to create a new PCL project in the same folder, edit the portable .csproj and copy the items from your platform-specific project file, then delete the platform-specific project and rename the portable one to the same name as the old platform-specific one.
Upvotes: 0