Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Porting Xamarin Windows 8 app to Windows 10 SDK

Tags:

c#

xamarin

I'm trying to run one of samples from this site.

The problem is: projects were made for Windows 8. When I open solution in Visual Studio, it tells me that I need to install Windows 8 SDK to proceed.

enter image description here

I'm using now Windows 10 SDK and I will no longer use SDK 8, so I'd rather not install this SDK and use new one intead. Can I somehow port this project to Windows 10 app?

How it looks like right now:

enter image description here

like image 778
Piotrek Avatar asked Apr 09 '16 19:04

Piotrek


1 Answers

Yes, porting is possible. I would suggest creating a new project in this solution (most solutions of this git already added UWP support, as I saw) and redo most stuff. On some projects which use platform specific code, this porting might not work since some APIs changed from WP8 to UWP - as you probably know.

After this procedure I still had problems - I had no working .appxmanifest file, so I cannot create a .pfx file. This keeps warning you the certifcate file is missing.

I am not sure if all steps are necessary. I leave this as homework ;)

Anyway, here I show you steps to port the TodoREST-project to UWP:

  • Unloading iOS and Droid project will make this easier
  • Uninstall all nuget packages from Portable and WinPhone81 project
  • Change portable class profile to Profile111 (uncheck WP8 Silverlight as target)
  • Now you can reinstall Xamarin.Forms and Newtonsoft.Json on portable project (uninstall was necessary to change profile - which was necessary because it raised some errors here)
  • Remove app.config from WinPhone81 project
  • Add a project.json file to WinPhone81 project and put in following content:

    {
        "dependencies": {
            "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
            "Xamarin.Forms": "2.0.0.6482"
        },
        "frameworks": {
            "uap10.0": { }
        },
        "runtimes": {
            "win10-arm": { },
            "win10-arm-aot": { },
            "win10-x86": { },
            "win10-x86-aot": { },
            "win10-x64": { },
            "win10-x64-aot": { }
        }
    }
    
  • Save everything and close WinPhone81 project

  • In file explorer go to folder and edit Package.appxmanifest

    • Exchange Package Tag by following:

      <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:m3="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="m3 mp"> 
      
    • Remove ... and add following instead:

      <Dependencies>
          <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0"/>
      </Dependencies>
      
  • Edit TodoREST.WinPhone81.csproj:

    • In first <PropertyGroup> replace <TargetPlatformVersion> by this:

      <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
      <TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
      <TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
      
    • Change ProjectTypeGuids to

      <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
      
    • On every PropertyGroup with Condition=... replace WINDOWS_PHONE_APP in DefineConstants by WINDOWS_UAP

    • Save
  • Reload project in Visual Studio
  • Edit MainPage.xaml and change <forms:WindowsPhonePage to <forms:WindowsPage and forms namespace to using:Xamarin.Forms.Platform.UWP (from .WinRT)
  • Here I had to restart VS2015 for any reason as it did not notice the project.json
  • Start project and debug!

I hope this answers your questions.

like image 94
Matt Avatar answered Sep 29 '22 12:09

Matt