Developing for Multiple Platforms with the .NET Framework

You can develop apps for both Microsoft and non-Microsoft platforms by using the .NET Framework and Visual Studio.

Options for cross-platform development

To develop for multiple platforms, you can share source code or binaries, and you can make calls between .NET Framework code and Windows Runtime APIs.

If you want to... Use...
Share source code between Windows Phone 8.1 and Windows 8.1 apps Shared projects (Universal Apps template in Visual Studio 2013, Update 2).

- Currently no Visual Basic support.
- You can separate platform-specific code by using #if statements.

For details, see:

- Build apps that target Windows and Windows Phone by using Visual Studio (MSDN article)
- Using Visual Studio to build Universal XAML Apps (blog post)
- Using Visual Studio to Build XAML Converged Apps (video)
Share binaries between apps that target different platforms Portable Class Library projects for code that is platform-agnostic.

- This approach is typically used for code that implements business logic.
- You can use Visual Basic or C#.
- API support varies by platform.
- Portable Class Library projects that target Windows 8.1 and Windows Phone 8.1 support Windows Runtime APIs and XAML. These features aren't available in older versions of the Portable Class Library.
- If needed, you can abstract out platform-specific code by using interfaces or abstract classes.

For details, see:

- Portable Class Library (MSDN article)
- How to Make Portable Class Libraries Work for You (blog post)
- Using Portable Class Library with MVVM (MSDN article)
- App Resources for Libraries That Target Multiple Platforms (MSDN article)
- .NET Portability Analyzer (Visual Studio extension)
Share source code between apps for platforms other than Windows 8.1 and Windows Phone 8.1 Add as link feature.

- This approach is suitable for app logic that's common to both apps but not portable, for some reason. You can use this feature for C# or Visual Basic code.
For example, Windows Phone 8 and Windows 8 share Windows Runtime APIs, but Portable Class Libraries do not support Windows Runtime for those platforms. You can use Add as link to share common Windows Runtime code between a Windows Phone 8 app and a Windows Store app that targets Windows 8.

For details, see:

- Share code with Add as Link (MSDN article)
- How to: Add Existing Items to a Project (MSDN article)
Write Windows Store apps using the .NET Framework or call Windows Runtime APIs from .NET Framework code Windows Runtime APIs from your .NET Framework C# or Visual Basic code, and use the .NET Framework to create Windows Store apps. You should be aware of API differences between the two platforms. However, there are classes to help you work with those differences.

For details, see:

- .NET Framework Support for Windows Store Apps and Windows Runtime (MSDN article)
- Passing a URI to the Windows Runtime (MSDN article)
- System.IO.WindowsRuntimeStreamExtensions (MSDN API reference page)
- System.WindowsRuntimeSystemExtensions (MSDN API reference page)
Build .NET Framework apps for non-Microsoft platforms Portable Class Library reference assemblies in the .NET Framework, and a Visual Studio extension or third-party tool such as Xamarin.

For details, see:

- Portable Class Library now available on all platforms. (blog post)
- Xamarin (Xamarin website)
Use JavaScript and HTML for cross-platform development Universal App templates in Visual Studio 2013, Update 2 to develop against Windows Runtime APIs for Windows 8.1 and Windows Phone 8.1. Currently, you can’t use JavaScript and HTML with .NET Framework APIs to develop cross-platform apps.

For details, see:

- JavaScript Project Templates
- Porting a Windows Runtime app using JavaScript to Windows Phone