The portable libraries are the response to the growing profile fragmentation in .NET frameworks. With help of portable libraries you can share code between different runtimes without dreadful
#ifdef PLATFORM
statements or even worse “Add as Link” source file sharing practices.
If you have an existing .net class library which you would like to reference from a different runtime (e.g. you have a .NET Framework 4.5 library which you would like to reference from a Windows Store project), you can either create a new portable class library and move the classes there or edit the existing .csproj file and change the XML directly. The following example shows how to convert a .NET Framework 4.5 library to a Portable Class Library.
First Unload the Project and change the following settings in the .csproj file:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
to:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable
\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
and add the following keys to the first property group in order to get visual studio to show the framework picker dialog:
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
After that you can select the frameworks in the Library Tab of the Portable Library:
As last step, delete any framework references from the library as you have them already referenced via the .NET Portable Subset.
[1] Cross-Platform Development with the .NET Framework – http://msdn.microsoft.com/en-us/library/gg597391.aspx
[2] Framework Profiles in .NET: http://nitoprograms.blogspot.de/2012/05/framework-profiles-in-net.html
- Share This Post:
- Technorati Short Url: http://wblo.gs/dAl