受欢迎的博客标签

How to Building an Android app require .NET 6  with .NET MAUI Step by step?

Published

.NET 6.0.0 Client App Samples for Android, iOS, macOS, and Windows

https://nicksnettravels.builttoroam.com/android-net-6/

 

NET MAUI is released. New releases .NET MAUI Update (https://devblogs.microsoft.com/dotnet/introducing-dotnet-maui-one-codebase-many-platforms/?WT.mc_id=dotnet-67511-masoucou)

.NET MAUI Learning Path (https://docs.microsoft.com/learn/paths/build-apps-with-dotnet-maui/?WT.mc_id=dotnet-67511-masoucou)

.NET MAUI website (https://dotnet.microsoft.com/apps/maui?WT.mc_id=dotnet-67511-masoucou)

Let's Learn .NET MAUI (https://docs.microsoft.com/events/learntv/lets-learn-dotnet-maui-june-2022/)

.NET MAUI Samples (https://github.com/dotnet/maui-samples) Latest News Migrating to .NET

 

.NET MAUI app sandbox

.NET MAUI apps provide the app sandbox. The app sandbox is a private area your application can work with. By default, no other applications can access this area other than the operating system. You can access the sandbox using the AppDataDirectory static property of the FileSystem class:

string path = FileSystem.AppDataDirectory;

https://docs.microsoft.com/en-us/learn/dotnet-maui/store-local-data/2-compare-storage-options

1. .NET MAUI, being an evolution of Xamarin.Forms. MAUI replaces Xamarin.

2.Managing Workload installation from the CLI is NOT recommended.

3. Instead you should install the latest Visual Studio preview to automatically get the newest release of .NET MAUI workloads installed.

Pre-requisites

Windows 11 and Windows 10 version 1809 or higher;Supported platforms for .NET MAUI apps

using Windows UI Library (WinUI) 3.

.NET Multi-platform App UI (MAUI)

.NET MAUI development environment

Visual Studio 2022 with the MAUI workload installed

Install OpenJDK 11.0
Insatll Windows UI Library (WinUI) 3   see:https://docs.microsoft.com/en-us/windows/apps/winui/winui3/
Install Visual Studio
Install or Update Android SDK packages    
     For more information see: https://aka.ms/dotnet-androidsdk-help
Install Android Emulator                              
    Use Visual Studio to create one if necessary: https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager
Install  .NET SDK
   .NET SDK - Workload Deduplication
    .NET SDK - EnableWorkloadResolver.sentinel
    .NET SDK - Workloads
     .NET SDK - Packs

目前MAUI已经支持Android、iOS (10+)、 Mac OS、Windows等平台;

不支持Linux ,Linux后期将由社区推动.

Note

The external NuGet Packages that your projects depend on cannot target Xamarin.iOS or Xamarin.Android; they must instead target net6.0-ios and net6.0-android.

 

Part 1:.NET MAUI development environment

VS2022 有两个通道,一个正式版,一个预览版,MAUI 在预览版通道上。

Install MAUI with Visual Studio 2022.To create .NET MAUI apps in Visual Studio, you'll need: 

Method 1:Install MAUI with Visual Studio 2022 Preview

Download the latest version of  Visual Studio 2022  preview (GUI instructions)

(Not Microsoft Visual Studio 2022 Release)

you will Visual Studio installed with the .NET workloads checked

Installing .NET MAUI with Visual Studio Installer

Step 1.Install the latest Visual Studio 2022 preview

Visual Studio 2022 installer yu must choice:
2.1 install or upgrade to the latest Visual Studio 2022 preview
2.2 including the optional workload .NET MAUI - select the “.NET Multi-platform App UI development” workload

Desktop & Mobile Options in Visual Studio 2022 17.3 Preview 1

Step 2: Set up your Microsoft Visual Studio so it can run the .NET MAUI framework.

Downloading workloads

You will need to set up your Microsoft Visual Studio so it can run the .NET MAUI framework. To do this, on the installation window, check the boxes for the following five workloads:

.NET Multi-platform App UI development

 For the brand-new Windows support,  .NET MAUI uses the WinUI 3 native UI components that come with the Windows App SDK (formerly Project Reunion).

step 3:  Install .NET SDK - Workloads(skip when vs2022 installed)  check list

.NET 6 introduces Android, iOS, and macOS SDKs for developing native applications. These provide the foundational mobile and desktop pieces for the new .NET MAUI.

– microsoft-android-sdk-full (Microsoft.NET.Sdk.Android.Manifest-6.0) installed.
  – microsoft-ios-sdk-full (Microsoft.NET.Sdk.iOS.Manifest-6.0) installed.
  – microsoft-maccatalyst-sdk-full (Microsoft.NET.Sdk.MacCatalyst.Manifest-6.0) installed.
  – microsoft-tvos-sdk-full (Microsoft.NET.Sdk.tvOS.Manifest-6.0) installed.
  – microsoft-macos-sdk-full (Microsoft.NET.Sdk.macOS.Manifest-6.0) installed.

 

dotnet workload search

Workload ID       Description                                                          
---------------------------------------------------------------------------------------

android               .NET SDK Workload for building Android applications.
android-33            Preview support for Android API-33.
ios                   .NET SDK Workload for building iOS applications.
maccatalyst           .NET SDK Workload for building macOS applications with MacCatalyst.
macos                 .NET SDK Workload for building macOS applications.
maui                  .NET MAUI SDK for all platforms
maui-android          .NET MAUI SDK for Android
maui-desktop          .NET MAUI SDK for Desktop
maui-ios              .NET MAUI SDK for iOS
maui-maccatalyst      .NET MAUI SDK for Mac Catalyst
maui-mobile           .NET MAUI SDK for Mobile
maui-tizen            .NET MAUI SDK for Tizen
maui-windows          .NET MAUI SDK for Windows
tvos                  .NET SDK Workload for building tvOS applications.
wasm-tools            .NET WebAssembly 生成工具

 

F:\Thirdprogram2\vs2022p>dotnet workload update

正在跳过 NuGet 包签名验证。
已更新广告清单 microsoft.net.sdk.maccatalyst。
已更新广告清单 microsoft.net.sdk.android。
已更新广告清单 microsoft.net.sdk.ios。
已更新广告清单 microsoft.net.sdk.tvos。
已更新广告清单 microsoft.net.sdk.maui。
已更新广告清单 microsoft.net.sdk.macos。
已更新广告清单 microsoft.net.workload.emscripten。
已更新广告清单 microsoft.net.workload.mono.toolchain。

已成功更新工作负载: maui。

path

C:\>cd C:\Program Files\dotnet\sdk-manifests\6.0.300

C:\Program Files\dotnet\sdk-manifests\6.0.300>dir
 驱动器 C 中的卷没有标签。
 卷的序列号是 8857-136A

 C:\Program Files\dotnet\sdk-manifests\6.0.300 的目录

2022/05/25  02:26    <DIR>          .
2022/05/25  02:26    <DIR>          ..
2022/05/25  06:55    <DIR>          microsoft.net.sdk.android
2022/05/25  06:55    <DIR>          microsoft.net.sdk.ios
2022/05/25  06:55    <DIR>          microsoft.net.sdk.maccatalyst
2022/05/25  06:55    <DIR>          microsoft.net.sdk.macos
2022/05/25  06:55    <DIR>          microsoft.net.sdk.maui
2022/05/25  06:55    <DIR>          microsoft.net.sdk.tvos
2022/05/28  03:26    <DIR>          microsoft.net.workload.emscripten
2022/05/25  06:55    <DIR>          microsoft.net.workload.mono.toolchain

C:\Program Files\dotnet\sdk-manifests\6.0.300\microsoft.net.sdk.android\WorkloadManifest.json

{
  "version": "32.0.301",
  "workloads": {
    "android": {
      "description": ".NET SDK Workload for building Android applications.",
      "packs": [
        "Microsoft.Android.Sdk",
        "Microsoft.Android.Ref.31",
        "Microsoft.Android.Ref.32",
        "Microsoft.Android.Runtime.32.android-arm",
        "Microsoft.Android.Runtime.32.android-arm64",
        "Microsoft.Android.Runtime.32.android-x86",
        "Microsoft.Android.Runtime.32.android-x64",
        "Microsoft.Android.Templates"
      ],
      "platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ],
      "extends" : [ "microsoft-net-runtime-android", "microsoft-net-runtime-android-aot" ]
    },
    "android-33": {
      "description": "Preview support for Android API-33.",
      "packs": [
        "Microsoft.Android.Ref.33",
        "Microsoft.Android.Runtime.33.android-arm",
        "Microsoft.Android.Runtime.33.android-arm64",
        "Microsoft.Android.Runtime.33.android-x86",
        "Microsoft.Android.Runtime.33.android-x64"
      ],
      "platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ],
      "extends" : [ "android" ]
    }
  },

Method 2:Installing .NET MAUI with Command line(command-line instructions)

windows  10

install .NET SDK 6.0.300
dotnet nuget locals all --clear
install SDK 20348( winsdksetup.exe) https://go.microsoft.com/fwlink/?linkid=2164145
dotnet workload install maui `
  --from-rollback-file https://aka.ms/dotnet/maui/main.json `
  --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-a21b9a2d/nuget/v3/index.json `
  --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-52e9452f-3/nuget/v3/index.json `
  --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json `
  --source https://api.nuget.org/v3/index.json

 

dotnet workload  install <WORKLOAD_ID>         安装一个或多个工作负载。
dotnet workload  update                        更新所有已安装的工作负载。
dotnet workload  list                          列出可用的工作负载。
dotnet workload  search <SEARCH_STRING>        搜索可用的工作负载。
dotnet workload  uninstall <WORKLOAD_ID>       卸载一个或多个工作负载。
dotnet workload  repair                        修复工作负载安装。
dotnet workload  restore <PROJECT | SOLUTION>  还原项目所需的工作负载。

Step 1: Install .NET MAUI

https://github.com/dotnet/maui/blob/main/.github/DEVELOPMENT.md

To  install .NET MAUI you can execute(run cmd as Administrator):

dotnet workload install maui

 

This MAUI workload includes the .NET 6 SDK, the MAUI SDK, and MAUI templates.

output

D:\tmp>dotnet workload install maui

正在跳过 NuGet 包签名验证。
Downloading Microsoft.Maui.Core.Ref.android.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Runtime.android.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Ref.android.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Runtime.android.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Ref.android.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Runtime.android.Msi.x64 (6.0.312)
Downloading Microsoft.AspNetCore.Components.WebView.Maui.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Dependencies.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Sdk.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Extensions.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Graphics.Msi.x64 (6.0.300)
Downloading Microsoft.Maui.Resizetizer.Sdk.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Templates.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Ref.any.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Runtime.any.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Ref.any.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Runtime.any.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Ref.any.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Runtime.any.Msi.x64 (6.0.312)
Downloading Microsoft.Android.Sdk.Windows.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Ref.31.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Ref.32.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Runtime.32.android-arm.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Runtime.32.android-arm64.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Runtime.32.android-x86.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Runtime.32.android-x64.Msi.x64 (32.0.301)
Downloading Microsoft.Android.Templates.Msi.x64 (32.0.301)
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x86.Msi.x64 (6.0.5)
Downloading Microsoft.NET.Runtime.MonoAOTCompiler.Task.Msi.x64 (6.0.5)
Downloading Microsoft.NET.Runtime.MonoTargets.Sdk.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64.Msi.x64 (6.0.5)
Downloading Microsoft.Maui.Core.Ref.ios.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Runtime.ios.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Ref.ios.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Runtime.ios.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Ref.ios.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Runtime.ios.Msi.x64 (6.0.312)
Downloading Microsoft.iOS.Sdk.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Windows.Sdk.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Ref.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Runtime.ios-arm.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Runtime.ios-arm64.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Runtime.iossimulator-x86.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Runtime.iossimulator-x64.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Runtime.iossimulator-arm64.Msi.x64 (15.4.303)
Downloading Microsoft.iOS.Templates.Msi.x64 (15.4.303)
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Msi.x64 (6.0.5)
Downloading Microsoft.Maui.Core.Ref.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Core.Ref.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Core.Runtime.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Controls.Ref.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Controls.Runtime.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Essentials.Ref.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.tizen.Msi.x64 (6.0.312)
正在安装 Microsoft.Maui.Essentials.Runtime.tizen.6.0.312.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Runtime.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Ref.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Runtime.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Ref.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Runtime.maccatalyst.Msi.x64 (6.0.312)
Downloading Microsoft.MacCatalyst.Sdk.Msi.x64 (15.4.303)
Downloading Microsoft.MacCatalyst.Ref.Msi.x64 (15.4.303)
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.Msi.x64 (15.4.303)
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-x64.Msi.x64 (15.4.303)
Downloading Microsoft.MacCatalyst.Templates.Msi.x64 (15.4.303)
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Msi.x64 (6.0.5)
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Msi.x64 (6.0.5)
Downloading Microsoft.Maui.Core.Ref.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Core.Runtime.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Ref.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Controls.Runtime.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Ref.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Essentials.Runtime.win.Msi.x64 (6.0.312)
Downloading Microsoft.Maui.Graphics.Win2D.WinUI.Desktop.Msi.x64 (6.0.300)

已成功安装的工作负载 maui。

 

 dotnet workload search

列出可安装的工作负载

Workload ID       Description                                                          
---------------------------------------------------------------------------------------
android           .NET SDK Workload for building Android applications.                 
android-aot       .NET SDK Workload for building Android applications with AOT support.
macos             .NET SDK Workload for building macOS applications.                   
maui-android      .NET MAUI SDK for Android                                            
maui-windows      .NET MAUI SDK for Windows                                            
wasm-tools        .NET WebAssembly build tools  

 

 

Part 2: maui-check dotnet tool

 maui-check dotnet tool  with each release as it does additional validation of your development environment to help you be successful: 
checking for OpenJDK, emulators, Xcode, Visual Studio versions, and more.

 

 

 

Installing Download and Install Microsoft OpenJDK 11.

 – 11.0.10 (C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot\bin\..)
  – Set Environemnt Variable: JAVA_HOME=C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot
  – 16 (F:\Thirdprogram\jdk)
  – 16 (C:\Program Files\Common Files\Oracle\Java)

Install Visual Studio 16.10.0

– 16.10.2 - D:\Thirdprogram2\vs2019

Install or Update Android SDK packages

Android SDK manager

      under Tools > Android > Android SDK manager.

– emulator (30.7.5)
  – build-tools;30.0.2 (30.0.2)
  – platforms;android-30 (3)
  – system-images;android-30;google_apis;x86 (9)
  – platform-tools (31.0.2)

Install Android Emulator

Use Visual Studio to create one if necessary: https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager

Install  .NET SDK

 – 6.0.100-preview.5.21302.13 - C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13

 

 

Install  .NET SDK - Packs

Installed Pack: Microsoft.Maui.Templates.
Installed Pack: Microsoft.Android.Sdk

 – Microsoft.Maui.Templates (6.0.100-preview.5.794) installed.
  – Microsoft.Android.Sdk (30.0.100-preview.5.28) installed.
  – Microsoft.Android.Sdk.BundleTool (30.0.100-preview.5.28) installed.
  – Microsoft.Android.Ref (30.0.100-preview.5.28) installed.
  – Microsoft.Android.Templates (30.0.100-preview.5.28) installed.
  – Microsoft.iOS.Sdk (14.5.100-preview.5.894) installed.
  – Microsoft.iOS.Windows.Sdk (14.5.100-preview.5.894) installed.
  – Microsoft.iOS.Ref (14.5.100-preview.5.894) installed.
  – Microsoft.iOS.Templates (14.5.100-preview.5.894) installed.
  – Microsoft.MacCatalyst.Sdk (14.5.100-preview.5.894) installed.
  – Microsoft.MacCatalyst.Ref (14.5.100-preview.5.894) installed.
  – Microsoft.MacCatalyst.Templates (14.5.100-preview.5.894) installed.
  – Microsoft.tvOS.Sdk (14.5.100-preview.5.894) installed.
  – Microsoft.tvOS.Ref (14.5.100-preview.5.894) installed.
  – Microsoft.tvOS.Templates (14.5.100-preview.5.894) installed.
  – Microsoft.macOS.Sdk (11.3.100-preview.5.894) installed.
  – Microsoft.macOS.Ref (11.3.100-preview.5.894) installed.
  – Microsoft.macOS.Templates (11.3.100-preview.5.894) installed.

Tools and SDKs required by .NET MAUI

.NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML.

Using .NET MAUI, you can develop apps that can run on Android, iOS, macOS, and Windows from a single shared code-base.

To create .NET Multi-platform App UI (MAUI) apps, you currently require .NET 6  with .NET MAUI and the platform SDKs for Android, iOS, macOS, tvOS, and Mac Catalyst.

OpenJDK 11.0
Android SDK
Android Emulator
.NET SDK
.NET SDK - Workload Deduplication
.NET SDK - EnableWorkloadResolver.sentinel

 .NET SDK - Workloads
- microsoft-android-sdk-full
- microsoft-ios-sdk-full

.NET SDK - Packs
- Microsoft.Maui.Templates
- Microsoft.Android.Sdk

Microsoft Visual Studio Enterprise 2022 (64 位) - Preview
版本 17.3.0 Preview 1.1


 

 

Install .NET MAUI and Dependencies-CLI



1. Install  .NET SDK 6.0

Download and run the 6.0.300 x64 .NET 6 SDK installer.

.NET 6 introduces Android, iOS, and macOS SDKs for developing native applications. These provide the foundational mobile and desktop pieces for the new .NET Multi-platform App UI

dotnet --version
6.0.300

When you install the .NET SDK, you receive over a dozen built-in templates for creating projects..NET default templates for dotnet new

C:\Windows\system32>dotnet new android -o ddd
No templates found matching: 'android'.
To list installed templates, run 'dotnet new --list'.
To search for the templates on NuGet.org, run 'dotnet new android --search'.

 

C:\Windows\system32>dotnet new --list
Template Name                                 Short Name           Language    Tags
--------------------------------------------  -------------------  ----------  ----------------------
Console Application                           console              [C#],F#,VB  Common/Console
Class Library                                 classlib             [C#],F#,VB  Common/Library
WPF Application                               wpf                  [C#],VB     Common/WPF
WPF Class library                             wpflib               [C#],VB     Common/WPF
WPF Custom Control Library                    wpfcustomcontrollib  [C#],VB     Common/WPF
WPF User Control Library                      wpfusercontrollib    [C#],VB     Common/WPF
Windows Forms App                             winforms             [C#],VB     Common/WinForms
Windows Forms Class Library                   winformslib          [C#],VB     Common/WinForms
Windows Forms Control Library                 winformscontrollib   [C#],VB     Common/WinForms
Worker Service                                worker               [C#],F#     Common/Worker/Web
MSTest Test Project                           mstest               [C#],F#,VB  Test/MSTest
NUnit 3 Test Item                             nunit-test           [C#],F#,VB  Test/NUnit
NUnit 3 Test Project                          nunit                [C#],F#,VB  Test/NUnit
xUnit Test Project                            xunit                [C#],F#,VB  Test/xUnit
Razor Page                                    page                 [C#]        Web/ASP.NET
MVC ViewImports                               viewimports          [C#]        Web/ASP.NET
MVC ViewStart                                 viewstart            [C#]        Web/ASP.NET
Razor Component                               razorcomponent       [C#]        Web/ASP.NET
Blazor Server App                             blazorserver         [C#]        Web/Blazor
Blazor WebAssembly App                        blazorwasm           [C#]        Web/Blazor/WebAssembly
ASP.NET Core Empty                            web                  [C#],F#     Web/Empty
ASP.NET Core Web App (Model-View-Controller)  mvc                  [C#],F#     Web/MVC
ASP.NET Core Web App                          webapp               [C#]        Web/MVC/Razor Pages
ASP.NET Core with Angular                     angular              [C#]        Web/MVC/SPA
ASP.NET Core with React.js                    react                [C#]        Web/MVC/SPA
ASP.NET Core with React.js and Redux          reactredux           [C#]        Web/MVC/SPA
Razor Class Library                           razorclasslib        [C#]        Web/Razor/Library
ASP.NET Core Web API                          webapi               [C#],F#     Web/WebAPI
ASP.NET Core gRPC Service                     grpc                 [C#]        Web/gRPC
global.json file                              globaljson                       Config
NuGet Config                                  nugetconfig                      Config
Web Config                                    webconfig                        Config
dotnet gitignore file                         gitignore                        Config
Dotnet local tool manifest file               tool-manifest                    Config
Solution File                                 sln                              Solution
Protocol Buffer File                          proto                            Web/gRPC

 

you can build and run your .NET MAUI application from CLI using one of the following commands:

dotnet build -t:Run -f net6.0-android

2. Install .NET Multi-Platform App UI Workload

You will need the Android SDK installed。You can install these platform SDKs:

$ dotnet workload install microsoft-android-sdk-full
$ dotnet workload install microsoft-ios-sdk-full
$ dotnet workload install microsoft-maccatalyst-sdk-full
$ dotnet workload install microsoft-macos-sdk-full
$ dotnet workload install microsoft-tvos-sdk-full

3. Install Microsoft OpenJDK 11 

 

 

The full set of .NET 6 TFMs, including operating-specific ones follows.

net6.0
net6.0-android
net6.0-ios
net6.0-maccatalyst
net6.0-macos
net6.0-tvos
net6.0-windows

 

Start an Android Emulator

Start an Android Emulator with the following command:

"C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE" -no-boot-anim -avd pixel_5_-_api_30 -prop monodroid.avdname=pixel_5_-_api_30

 

.NET MAUI Check tool

step 1:Install .NET MAUI Check tool

C:\Windows\system32>dotnet tool install -g redth.net.maui.check
已安装工具“redth.net.maui.check”。

Step 2:Update the tool to the latest version

dotnet tool update -g redth.net.maui.check

output

C:\Users\Administrator2>dotnet tool update -g redth.net.maui.check
工具“redth.net.maui.check”已重新安装最新稳定版本(版本“0.10.0”)。

Step 3:

maui-check

output

d:\tmp>maui-check
      _   _   _____   _____     __  __      _      _   _   ___
     | \ | | | ____| |_   _|   |  \/  |    / \    | | | | |_ _|
     |  \| | |  _|     | |     | |\/| |   / _ \   | | | |  | |
  _  | |\  | | |___    | |     | |  | |  / ___ \  | |_| |  | |
 (_) |_| \_| |_____|   |_|     |_|  |_| /_/   \_\  \___/  |___|

¤ .NET MAUI Check v0.10.0.0 ¤
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
This tool will attempt to evaluate your .NET MAUI development environment.
If problems are detected, this tool may offer the option to try and fix them for you, or suggest a way to fix them
yourself.

Thanks for choosing .NET MAUI!
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
? Synchronizing configuration... ok
? Scheduling appointments... ok

? OpenJDK 11.0 Checkup...
  – 11.0.12 (C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin\..)
  – 11.0.10 (C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot\bin\..)
  – 16 (C:\Program Files\Common Files\Oracle\Java)

? Visual Studio 17.1.0-pre.3.0 Checkup...
  – 17.2.1 - F:\Thirdprogram2\vs2022e
  – 17.3.0-pre.1.0 - D:\Thirdprogram2\vs2022Preview

? Android SDK Checkup...
  – emulator (30.7.5)
  × build-tools;31.0.0 (31.0.0) missing.
  × platforms;android-31 (1) missing.
  × system-images;android-31;google_apis;x86_64 (6) missing.
  – platform-tools (31.0.2)
  × cmdline-tools;5.0 (5.0) missing.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
¤ Recommendation: Install or Update Android SDK packages
Your Android SDK has missing or outdated packages.
You can use the Android SDK Manager to install / update them.
For more information see: https://aka.ms/dotnet-androidsdk-help
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

! Attempt to fix? [y/n] (y): y
? Attempting to fix: Android SDK
  – Downloading
https://dl.google.com/android/repository/09489e417c0a266f2862ddd82b4ac29a1b7af55e.build-tools_r31-windows.zip ...
  – Downloading https://dl.google.com/android/repository/platform-31_r01.zip ...
  – Downloading https://dl.google.com/android/repository/sys-img/google_apis/x86_64-31_r09.zip ...
  – Downloading https://dl.google.com/android/repository/emulator-windows_x64-8420304.zip ...
  – Downloading https://dl.google.com/android/repository/commandlinetools-win-7583922_latest.zip ...

 

Fix applied.  Checking again...

? Android SDK Checkup...
  – emulator (31.2.10)
  – build-tools;31.0.0 (31.0.0)
  – platforms;android-31 (1)
  – system-images;android-31;google_apis;x86_64 (9)
  – platform-tools (31.0.2)
  – cmdline-tools;5.0 (5.0)

? Android Emulator Checkup...

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
¤ Recommendation: Create an Android Emulator
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

! Attempt to fix? [y/n] (y):

see:https://www.iaspnetcore.com/blog/blogpost/5d9793be72c1772b244a4e76/githubcom-acceleration-tutorial

https://github.com/redth/dotnet-maui-check

 

.NET MAUI templates do not appear in Visual Studio

The .NET MAUI templates might not appear in Visual Studio if you also have .NET 7 Preview installed.

When installing both Visual Studio 2022 and .NET 7 preview, the .NET MAUI templates may not appear in Visual Studio 2022.

To build .NET MAUI projects you must use the latest stable release of .NET 6.

.NET MAUI will be included in a future preview of .NET 7, at which time you could use .NET MAUI side by side from both stable and preview versions.


uninstall .NET 7

 

.NET 8 MAUI 

Install .NET 8

Install  .NET MAUI workload with Visual Studio 17.8+ standalone installer

Install the Android SDK

 

严重性	代码	说明	项目	文件	行	禁止显示状态
错误	XA5300	The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://aka.ms/dotnet-android-install-sdk
To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path.	MauiApp1	C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.43\tools\Xamarin.Android.Tooling.targets	70	

https://aka.ms/dotnet-android-install-sdk

 

Useful links

.NET 6 中不使用VPN的情况下通过修改host搭建 MAUI开发环境

https://www.section.io/engineering-education/getting-started-with-dot-net-maui-for-cross-platform-apps/

https://devblogs.microsoft.com/dotnet/category/maui/

 

Announcing .NET MAUI in .NET 8

https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-in-dotnet-8/

https://github.com/dotnet/maui/releases

source project

 

Check out the .NET MAUI Workshop for more examples.

Tizen .NET

Visit the Tizen .NET introduction to get started. While the platform support is part of .NET MAUI SDK and we’ve added the scaffolding for Tizen to the .NET MAUI template project, the required workload dependencies are distributed through a separate installation experience maintained by Tizen.

Tizen将由三星推动(Tizen 是两大Linux联盟LiMo Foundation和Linux Foundation整合资源优势,携手英特尔和三星电子,共同开发针对手机和其它设备的操作系统,Tizen 相当于三星的“鸿蒙系统”)

barcode scanning tookit support MAUI

https://github.com/Redth/BigIslandBarcoding

.NET Podcasts - Sample Application

https://github.com/microsoft/dotnet-podcasts

 

.NET MAUI - Workshop

https://github.com/dotnet-presentations/dotnet-maui-workshop

 

https://github.com/dotnet/maui/wiki/.NET-7-and-.NET-MAUI

enabled Developer Mode on windows

https://docs.microsoft.com/en-us/dotnet/maui/get-started/first-app?pivots=devices-windows

https://github.com/microsoft/dotnet-podcasts