4

I have a Xamarin.Forms Shared project (not PCL) application and want to migrate to .NetStandard project. I checked in online, but not get any reference. I welcomes your hints

Thanks,

Bharathi
  • 1,288
  • 2
  • 14
  • 40

1 Answers1

5
  1. Create a new .NET Standard Project in the same Folder as your old shared project and than just add all files to the new project using Drag and Drop from SolutionExplorer in Visual Studio.
  2. Add require packages
  3. Replace your platform specific code

Like

 #if __MOBILE__
// Xamarin iOS or Android-specific code
#endif

//OR

#if __IOS__
// iOS-specific code
#endif 

With

if(Device.Idiom == TargetIdiom.Phone)//TargetIdiom.Tablet OR what ever you want
{
 -----
}
if(Device.RuntimePlatform == Device.iOS)//OR Device.Android
{
 -----
}
Akshar M.
  • 146
  • 3
  • Thanks, this worked well, just needed to remove some duplicated embedded resources, see here: https://stackoverflow.com/questions/46748950/duplicate-embeddedresource-items-were-included-after-migrate-to-net-standard – Andy Sinclair Jan 24 '20 at 07:14