6 Ekim 2016 Perşembe

Some issues and solutions while converting your Xamarin.Forms Project into .Net Standard


Eğer Xamarin.Forms projenizi .Net Standard'a çevirmek istiyorsanız eminim aynı bizim gibi pek çok sorunla karşılaşırsınız. Eğer vakit bulursam karşılaştığımız tüm sorunları ve çözümleri yazacağım ancak hızlıca en çok sinir edeni paylaşmadan edemedim.  Zira bu konuyla ilgili ne hikmetse nette tek bir insan yazmış  ve yanlış yazmış. :@ MVP olacak bir de :P

Eğer projenizi .Net Standard'a çevirdikten, nuget packages'larınızı restore ettikten sonra Android projenizde

provides a compile-time reference assembly for mscorlib on MonoAndroid,Version=v6.0, but there is no run-time assembly compatible with win.

error CS1703: Multiple assemblies with equivalent identity have been imported
hatası alıyorsanız, pcl projenizdeki project.json dosyanızda;

"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
 paketini şu şekilde güncelleyin;

"Microsoft.NETCore.Portable.Compatibility": {
      "version": "1.0.1",
      "type": "build"
    },

 şimdi de rebuild alın. Aaaa çalıştı. (Buna ulaşmak yarım günden fazla sürdü :( )


Bu arada örnek olması açısından project.json dosyalarımı paylaşmak istiyorum;

PCL project.json;

{
  "supports": {},
  "dependencies": {
    "AutoMapper": "5.0.0",
    "Acr.DeviceInfo": "4.0.2",
    "Acr.UserDialogs": "6.2.3",
    "CommonMark.NET": "0.14.0",
    "Microsoft.NETCore.Portable.Compatibility": {
      "version": "1.0.1",
      "type": "build"
    },
    "MonoCode.Forms": "1.0.0-pre05",
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1",
    "PCLStorage": "1.0.2",
    "Plugin.Permissions": "1.1.7",
    "System.ComponentModel": "4.0.1",
    "Toasts.Forms.Plugin": "3.1.0",
    "Xam.Plugin.DeviceInfo": "2.0.2",
    "Xam.Plugin.Geolocator": "4.0.0-beta4",
    "Xamarin.Forms": "2.3.2.127",
    "Xamarin.Insights": "1.12.3"
  },
  "frameworks": {
    "netstandard1.3": {
      "imports": "portable-net45+win8+wpa81"
    }
  }
}

Droid project.json;


{
  "dependencies": {
    "Acr.DeviceInfo": "4.0.2",
    "Acr.Support": "2.1.0",
    "Acr.UserDialogs": "6.2.3",
    "AndHUD": "1.2.0",
    "CommonMark.NET": "0.14.0",
    "ExifLib.PCL": "1.0.1",
    "MonoCode.Forms": "1.0.0-pre05",
    "Newtonsoft.Json": "9.0.1",
    "PCLStorage": "1.0.2",
    "Plugin.CurrentActivity": "1.0.1",
    "Plugin.Permissions": "1.1.7",
    "RestSharp": "105.2.3",
    "Toasts.Forms.Plugin": "3.1.0",
    "Xam.Plugin.DeviceInfo": "2.0.2",
    "Xam.Plugin.Geolocator": "4.0.0-beta4",
    "Xamarin.Android.Support.Animated.Vector.Drawable": "23.3.0",
    "Xamarin.Android.Support.Design": "23.3.0",
    "Xamarin.Android.Support.v4": "23.3.0",
    "Xamarin.Android.Support.v7.AppCompat": "23.3.0",
    "Xamarin.Android.Support.v7.CardView": "23.3.0",
    "Xamarin.Android.Support.v7.MediaRouter": "23.3.0",
    "Xamarin.Android.Support.v7.RecyclerView": "23.3.0",
    "Xamarin.Android.Support.Vector.Drawable": "23.3.0",
    "Xamarin.Forms": "2.3.2.127",
    "Xamarin.GooglePlayServices.Base": "29.0.0.2",
    "Xamarin.GooglePlayServices.Basement": "29.0.0.2",
    "Xamarin.GooglePlayServices.Gcm": "29.0.0.2",
    "Xamarin.GooglePlayServices.Measurement": "29.0.0.2",
    "Xamarin.Insights": "1.12.3"
  },
  "frameworks": {
    "MonoAndroid,Version=v7.0": {}
  },
  "runtimes": {
    "win": {}
  }
}

iOS project.json;


{
  "dependencies": {
    "Acr.DeviceInfo": "4.0.2",
    "Acr.Support": "2.1.0",
    "Acr.UserDialogs": "6.2.3",
    "BTProgressHUD": "1.2.0.3",
    "ExifLib.PCL": "1.0.1",
    "Microsoft.Bcl": "1.1.10",
    "Microsoft.Bcl.Build": "1.0.21",
    "Microsoft.Net.Http": "2.2.29",
    "MonoCode.Forms": "1.0.0-pre05",
    "PCLStorage": "1.0.2",
    "RestSharp": "105.2.3",
    "Rx-Main": "2.2.5",
    "Toasts.Forms.Plugin": "3.1.0",
    "WebP.Touch": "1.0.2",
    "Xam.Plugin.DeviceInfo": "2.0.2",
    "Xam.Plugin.Geolocator": "4.0.0-beta4",
    "Xamarin.Forms": "2.3.2.127",
    "Xamarin.Insights": "1.12.3"
  },
  "frameworks": {
    "Xamarin.iOS,Version=v1.0": {}
  },
  "runtimes": {
    "win": {}
  }
}

İyi çalışmalar cinlerim.