Marvin Heng - Going through this slide, you will learn how to create a cross platform mobile app that's working on mobile, PC, Hololens & even XBOX with the latest .NET Standard in C#!
#hmheng @hmheng
#crossplatform #mobileapp #xamarin #windows #android #iOS #uwp #.netstandard
Click here for viewing full tutorial @ www.techconnect.io
Twitter: @hmheng
Blog: www.techconnect.io
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
App Development: Create Cross Platform Mobile App with .NETStandard 2.0
1. Create Cross
Platform Mobile
App with
.NETStandard2.0
Marvin Heng
Twitter : @hmheng
Blog : http://hmheng.azurewebsites.net
Github: https://github.com/hmheng
2. 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)
3. 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.
4. Introduction to Visual Studio 2017
Download & Install VS2017
on your PC or Mac if you don’t have one yet.
CLICK TO DOWNLOAD
COMMUNITY VERSION for Free
5. 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.
6. Create MobileApp with .NETStandard 2.0
1. After you have installed Visual Studio 2017 (VS2017) with
Cross-Platform development, launch it.
7. Create MobileApp with .NETStandard 2.0
2. 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
8. Create MobileApp with .NETStandard 2.0
3. Select Cross-Platform -> Cross Platform App (Xamarin) ->
Enter your App Name and then Hit OK.
3a
3b
3c
3d
9. Create MobileApp with .NETStandard 2.0
4. To make the following steps simple, we shall select Blank
App with Xamarin.Forms & PCL now. Then click OK.
4b
4a
4c
10. Create MobileApp with .NETStandard 2.0
5. While creating the platform-specified projects, VS2017 will
ask you for a Minimum Target Version & select Build 16299.
5
11. Create MobileApp with .NETStandard 2.0
6. Now, your app is ready to be compiled & running on your
PC/Android. But, we want to develop with .NETStandard 2.0!
2a
12. Create MobileApp with .NETStandard 2.0
7. So, in order to migrate it from PCL to .NETStandard 2.0, we
need to right click Solution at Solution Explorer.
2a
7
13. Create MobileApp with .NETStandard 2.0
8. Now, we will add a new .NETStandard 2.0 project to replace
PCL. Right click the Solution, Select Add -> New Project….
2a
8a
8b
14. Create MobileApp with .NETStandard 2.0
9. Select .NET Standard -> Class Library -> Enter
<namespace>.Core. Then click OK.
2a
9a
9b
9c
9e
15. Create MobileApp with .NETStandard 2.0
10. Pull all necessary files from PCL to .NET Standard project.
10a
10b
16. Create MobileApp with .NETStandard 2.0
11. We can delete the Class1.cs since we do not need it.
11a
11b
17. Create MobileApp with .NETStandard 2.0
12. Now, we can delete PCL. Right click the PCL in Solution
Explorer. Remove it from solution.
12a
12b
18. Create MobileApp with .NETStandard 2.0
13. After deleting PCL project, we need to install
Xamarin.forms & .NETStandard library from NuGet.
13a
13b
19. Create MobileApp with .NETStandard 2.0
14. First, let’s search for & install .NETStandard library to all
other projects.
14a
14b
14c
20. Create MobileApp with .NETStandard 2.0
15. To add Xamarin Forms to our newly created .NETStandard
project, search for Xamarin.Forms & install to the project.
15a
15b
15c
21. Publish First Web Application to Azure
16. You may get error of duplication while trying to build. We
need to remove following line from the project’s .csproj file.
16a
16b
22. Publish First Web Application to Azure
17. We add reference to .NETStandard project to all other
platform specific. Right click Project -> Add -> Reference
17a
17b
17c
23. Create MobileApp with .NETStandard 2.0
18. Tick the newly created project and click OK. Repeat the
same for Android & iOS.
18a
18b
26. Extras
In 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>
27. Extras
Understand which .NETStandard version is suitable for you
here. In nutshell, the lower version supports more platforms
while the higher version supports more APIs.
28. Extras
Get a sample source code to jump start your development
with .NET Standard 2.0.
29. Create Cross
Platform Mobile
App with
.NETStandard2.0
Marvin Heng
Twitter : @hmheng
Blog : http://hmheng.azurewebsites.net
Github: https://github.com/hmheng