创建第一个 .Net MAUI 项目

7

我尝试使用Visual Studio开发者命令提示符在Windows中创建Maui项目,执行以下命令:
命令:
dotnet new maui

但是它没有创建Maui项目,而是出现错误消息No templates found matching : maui
我已在我的计算机上安装了.Net 5和Visual Studio 2019。


1
https://github.com/dotnet/maui/wiki/FAQs - CodeCaster
https://github.com/Redth/dotnet-maui-check/issues/16 - Pavel Aristarkhov
5个回答

15

有一个已知问题,请手动安装模板:

dotnet new -i Microsoft.Maui.Templates

5

根据当前的文档,现在建议使用Visual Studio创建.NET Maui应用程序。

旧的建议:

我建议使用提供的检查工具,它会为您安装模板并确保一切准备就绪,以便使用Maui进行开发。

Install: dotnet tool install -g redth.net.maui.check

Run: maui-check --dev

This will check for:

OpenJdk / AndroidSDK
.NET 6 Preview SDK
.NET MAUI / iOS / Android workloads and packs
.NET MAUI Templates
Workload Resolver .sentinel files for dotnet and Visual Studio Windows/Mac
Currently does not install workloads required for WinUI3

在链接的 GitHub 页面中没有检查工具(我以为它是某个二进制文件?)。 - Lei Yang
@LeiYang - 看起来已经移动了,我修复了链接,但让我用官方文档更新答案。 - Jimenemex

2
这应该能帮助你:

https://github.com/dotnet/maui

https://github.com/dotnet/net6-mobile-samples

请看“使用IDE”部分:

使用IDE

将IDE集成到Visual Studio、Visual Studio for Mac和Visual Studio Code中仍在进行中。

Visual Studio

目前,您可以使用安装了Xamarin工作负载的Windows上的Visual Studio 2019 16.9,在执行一些手动步骤后运行基于.NET 6构建的iOS和Android应用程序。


2

若要进行Visual Studio集成,您需要至少16.11预览版1。使用maui-check工具在系统上安装/升级前提条件。该工具会不断更新,以确保安装了最新的MAUI功能。每次发布新的预览版(大约每月一次),请重新运行maui-check。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接