App Development: Create Cross Platform Mobile App with .NETStandard 2.0
-
Upload
hiang-meng-heng-marvin -
Category
Technology
-
view
47 -
download
1
Transcript of App Development: Create Cross Platform Mobile App with .NETStandard 2.0
![Page 1: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/1.jpg)
Create Cross Platform Mobile App with .NETStandard2.0Marvin HengTwitter : @hmhengBlog : http://hmheng.azurewebsites.netGithub: https://github.com/hmheng
![Page 2: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/2.jpg)
Pre-requisite• Installed Visual Studio 2017 for Windows with Xamarin
Cross-Platform component & all necessary platform-specific SDK.
• Xamarin.Forms 2.4 or above. (Click here to learn how to create a Xamarin.Forms app with Portable Class Library)
![Page 3: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/3.jpg)
Introduction to Visual Studio 2017• The First Class fully-featured integrated development
environment (IDE) for Android, iOS, Windows, web, and cloud development.
• Community free version comes with IntelliSense & connects to team management tools, such as Microsoft Team Services or GitHub, that increases developer’s efficiency & improves the experience.
• Available on Windows & MacOS.
![Page 4: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/4.jpg)
Introduction to Visual Studio 2017Download & Install VS2017
on your PC or Mac if you don’t have one yet.
CLICK TO DOWNLOAD COMMUNITY VERSION for Free
![Page 5: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/5.jpg)
Why Would We Need .NETStandard?• Defines uniform set of BCL APIs for all .NET
implementations to implement, independent of workload.• Enables developers to produce portable libraries that are
usable across .NET implementations, using this same set of APIs.
• Reduces or even eliminates conditional compilation of shared source due to .NET APIs, only for OS APIs.
![Page 6: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/6.jpg)
Create MobileApp with .NETStandard 2.01. After you have installed Visual Studio 2017 (VS2017) with Cross-Platform development, launch it.
![Page 7: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/7.jpg)
Create MobileApp with .NETStandard 2.02. We will create a Cross-Platform mobile app for Android, iOS& Windows UWP app. Let’s Select File -> New -> Project….
2
If you already have a Xamarin.Forms app, click here to jump over how to migrate your Existing Xamarin.Forms app from PCL to .NETStandard
![Page 8: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/8.jpg)
Create MobileApp with .NETStandard 2.03. Select Cross-Platform -> Cross Platform App (Xamarin) -> Enter your App Name and then Hit OK.
3a
3b
3c
3d
![Page 9: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/9.jpg)
Create MobileApp with .NETStandard 2.04. To make the following steps simple, we shall select Blank App with Xamarin.Forms & PCL now. Then click OK.
4b
4a
4c
![Page 10: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/10.jpg)
Create MobileApp with .NETStandard 2.05. While creating the platform-specified projects, VS2017 will ask you for a Minimum Target Version & select Build 16299.
5
![Page 11: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/11.jpg)
Create MobileApp with .NETStandard 2.06. Now, your app is ready to be compiled & running on your PC/Android. But, we want to develop with .NETStandard 2.0!
2a
![Page 12: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/12.jpg)
Create MobileApp with .NETStandard 2.07. So, in order to migrate it from PCL to .NETStandard 2.0, we need to right click Solution at Solution Explorer.
2a
7
![Page 13: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/13.jpg)
Create MobileApp with .NETStandard 2.08. Now, we will add a new .NETStandard 2.0 project to replace PCL. Right click the Solution, Select Add -> New Project….
2a
8a
8b
![Page 14: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/14.jpg)
Create MobileApp with .NETStandard 2.09. Select .NET Standard -> Class Library -> Enter <namespace>.Core. Then click OK.
2a
9a
9b
9c9e
![Page 15: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/15.jpg)
Create MobileApp with .NETStandard 2.010. Pull all necessary files from PCL to .NET Standard project.
10a
10b
![Page 16: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/16.jpg)
Create MobileApp with .NETStandard 2.011. We can delete the Class1.cs since we do not need it.
11a
11b
![Page 17: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/17.jpg)
Create MobileApp with .NETStandard 2.012. Now, we can delete PCL. Right click the PCL in Solution Explorer. Remove it from solution.
12a
12b
![Page 18: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/18.jpg)
Create MobileApp with .NETStandard 2.013. After deleting PCL project, we need to install Xamarin.forms & .NETStandard library from NuGet.
13a
13b
![Page 19: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/19.jpg)
Create MobileApp with .NETStandard 2.014. First, let’s search for & install .NETStandard library to all other projects.
14a
14b
14c
![Page 20: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/20.jpg)
Create MobileApp with .NETStandard 2.015. To add Xamarin Forms to our newly created .NETStandardproject, search for Xamarin.Forms & install to the project.
15a
15b
15c
![Page 21: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/21.jpg)
Publish First Web Application to Azure16. You may get error of duplication while trying to build. We need to remove following line from the project’s .csproj file.
16a
16b
![Page 22: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/22.jpg)
Publish First Web Application to Azure17. We add reference to .NETStandard project to all other platform specific. Right click Project -> Add -> Reference
17a
17b
17c
![Page 23: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/23.jpg)
Create MobileApp with .NETStandard 2.018. Tick the newly created project and click OK. Repeat the same for Android & iOS.
18a
18b
![Page 24: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/24.jpg)
Create MobileApp with .NETStandard 2.019. Now, let’s connect our phone & re-deploy again!
19
![Page 25: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/25.jpg)
Congratulation!Your Cross Platform Mobile App is now with .NET Standard 2.0!
![Page 26: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/26.jpg)
ExtrasIn case you need to install some PCL libraries to your new .NETStandard’s Xamarin Forms, you will need to add this to <namespace>.Core.csproject.
a
b
c
<PropertyGroup><TargetFramework>netstandard2.0</TargetFramework><PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
</PropertyGroup>
![Page 27: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/27.jpg)
ExtrasUnderstand which .NETStandard version is suitable for you here. In nutshell, the lower version supports more platforms while the higher version supports more APIs.
![Page 28: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/28.jpg)
ExtrasGet a sample source code to jump start your development with .NET Standard 2.0.
![Page 29: App Development: Create Cross Platform Mobile App with .NETStandard 2.0](https://reader031.fdocuments.us/reader031/viewer/2022022415/5a64796d7f8b9a27568b4877/html5/thumbnails/29.jpg)
Create Cross Platform Mobile App with .NETStandard2.0Marvin HengTwitter : @hmhengBlog : http://hmheng.azurewebsites.netGithub: https://github.com/hmheng