Search This Blog

Monday, 15 February 2016

Converting a Portable Class Library to a normal class library & Vice-versa - Without recreating the project

I happened to be experimenting with a portable class library in .net 4.5.
I had issues when I tried to connect to it through a normal Asp.net MVC project. Hence I wanted to re-convert it into a normal class library, but without deleting the project.
This is how I did it.

Step 1

Open your project file in notepad

Step 2

Locate the following
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
Replace it with
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Step 3
Locate the following and delete it
<ProjectTypeGuids>....</ProjectTypeGuids>
Now save your project file. To be safe, save it with a different name
Now try opening the newly saved .csproj file in Visual studio. You will be prompted to target a .net framework, select the framework you need to target and click ok.

The project will be loaded normally. Now right-click on the project in the solution explorer->Properties. It will show the Output type as Class Library.

No comments:

Post a Comment