The previous "Visual Studio 2017 create. NET Standard Class library compilation error Reason" has resolved the. NET Standard Class Library compilation problem, now can formally enter the topic. As a. NET cross-platform developer, you have to keep up with the times and respond to Microsoft changes. Microsoft is developing a version of. NET Standard 2.0, and is told that it will be the most complete API library, and that the PCL class libraries currently in use will be replaced. Considering the changes in the future, it is going to be PCL, all. NET Standard, from now on when you start a new Xamarin project.
Since 2.0 has not yet been officially released, Xamarin has not updated its template library to support. NET Standard, so many have to be set manually.
First step: Create a normal Prism.xamarin project
Step Two: Change the PCL class library to the standard class library.
1,vs2015 the old method, change it through the link button on the Project property page.
The following error is indicated:
You can delete all NuGet packages at this time and then add them back to the NuGet package after the operation is finished.
The conversion succeeds with the Microsoft.NETCore.Portable.Compatibility package and should be removed.
Edit the Project.json file, add the following settings, or you cannot add a NuGet package such as Xamarin:
{ "supports": {}, "dependencies": { "netstandard.library": "1.6.1" }, "Frameworks": { " netstandard1.4 ": { " Imports ":" Portable-net45+net45+wp8+win81+wpa8 "}} }
Remark :
Xamarin.Forms use the official version of 2.3.3.193 to compile the pass.
Class Library Properties:
2. Create a new. NET Standard class library directly and migrate the PCL content.
Note: Remember to change the location, otherwise the folder does not and ios.uwp,droid items in the sibling directory.
Add the following settings to the. csproj file:
netstandard1.4
$ (packagetargetfallback);p ortable-win+net45+wp8+win81+wpa8
Reload the project, put all the files of the PCL class library, and compile the project.
Class Library Properties:
Note 1:
Xamarin.Forms If you use the official version of 2.3.3.193, the compilation will xamlctask error.
Google's results, this is a xamarin version of Bug,beta-2.3.4-pre4 has been fixed.
https://bugzilla.xamarin.com/show_bug.cgi?id=53060
Upgrade to Beta-2.3.4-pre6 compiled successfully.
NOTE 2:
The following error will appear when the UWP project has a Microsoft.NETCore.UniversalWindowsPlatform of 5.1.0:
System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on uap,version=v10.0. However, there is no runtime assembly compatible with Win10-arm-aot.
One or more packages are incompatible with uap,version=v10.0 (WIN10-ARM-AOT).
System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on uap,version=v10.0. However, there is no runtime assembly compatible with Win10-x64-aot.
One or more packages are incompatible with uap,version=v10.0 (WIN10-X64-AOT).
System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on uap,version=v10.0. However, there is no runtime assembly compatible with Win10-x86-aot.
One or more packages are incompatible with uap,version=v10.0 (WIN10-X86-AOT).
Upgrading to the latest 5.3.1 compilation will be no problem.
Difference between the two
Method One:
- Project.json for package Management
- Property pages have no complex settings.
Method Two:
- . csproj files for package management.
- Property pages can be used for many settings such as startup objects.
In these differences, you should use the VS2017. NET Standard template to create a class library to handle future changes.
Xamarin+prism development of. NET Standard