简体   繁体   English

使用 .net maui 创建正常的 windows 桌面应用程序?

[英]create normal windows desktop application using .net maui?

I'm planing to create a cross platform application.我打算创建一个跨平台应用程序。 Minimal supported platforms should be android and windows.支持的最低平台应为 android 和 windows。 I'd like to end up with a classical windows executable, not a UWP app.我想最终得到一个经典的 windows 可执行文件,而不是 UWP 应用程序。 The new maui platform looks like it might fit.新的 maui 平台看起来很合适。

I've already downloaded the current pre-release version of visual studio 2022 and create a new maui project.我已经下载了 Visual Studio 2022 的当前预发布版本并创建了一个新的 maui 项目。 When I compile and run it on windows the application visual studio creates is a UWP app.当我在 windows 上编译并运行它时,Visual Studio 创建的应用程序是 UWP 应用程序。 The official microsoft page for maui states:毛伊岛的官方微软页面指出:

.NET Multi-platform App UI (.NET MAUI) apps can be written for the following platforms: .NET 多平台应用程序 UI (.NET MAUI) 应用程序可以为以下平台编写:

Android 5.0 (API 21) or higher. Android 5.0 (API 21) 或更高版本。 iOS 10 or higher. iOS 10 或更高。 macOS 10.13 or higher, using Mac Catalyst. macOS 10.13 或更高版本,使用 Mac Catalyst。 Windows 11 and Windows 10 version 1809 or higher, using Windows UI Library (WinUI) 3. Windows 11 和 Windows 10 版本 1809 或更高版本,使用 Windows UI 库 (WinUI) 3。

https://docs.microsoft.com/en-us/dotnet/maui/supported-platforms https://docs.microsoft.com/en-us/dotnet/maui/supported-platforms

The following issue on github also looks like it might be possible to create a widnows executable: github 上的以下问题看起来也可以创建一个 widnows 可执行文件:

Publishing to an exe (not self-contained) works but don't take the published folder files, take the build artifacts, see bullet 3 below for all the details发布到 exe(不是独立的)可以工作,但不要获取已发布的文件夹文件,获取构建工件,请参阅下面的项目符号 3 了解所有详细信息

https://github.com/dotnet/maui/issues/4329 https://github.com/dotnet/maui/issues/4329

I'm a bit confused about the details of the support for windows.我对 windows 的支持细节有点困惑。 Is only windows possible to create a UWP app or can I compile it to a normal desktop application?只有 windows 可以创建 UWP 应用程序,还是可以将其编译为普通桌面应用程序? Can I change the output to be a normal windows executable, if so how?我可以将 output 更改为普通的 windows 可执行文件,如果可以的话怎么办?

This is the only way that worked for me, but it is a little bugged.这是对我有用的唯一方法,但它有点错误。

Open a terminal and run the following command:打开终端并运行以下命令:

msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform="any CPU" /p:PublishSingleFile=true /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64

The build file can be found in \bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish构建文件可以在 \bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish 中找到

.NET Maui Apps are not UWP apps. .NET Maui 应用程序不是 UWP 应用程序。 They are built using WinUI 3 and the Windows App SDK which produces a Win32 app.它们是使用 WinUI 3 和 Windows 应用程序 SDK 构建的,该应用程序可生成 Win32 应用程序。 Information about the Windows App SDK can be found here and information regarding different app types can be found here .有关 Windows 应用程序 SDK 的信息可在 此处找到,有关不同应用类型的信息可在此处找到。

If you are asking if it is possible to publish a Windows executable file (.exe) then that is not possible.如果您询问是否可以发布 Windows 可执行文件 (.exe),那么这是不可能的。 .NET MAUI only allows publishing an MSIX package. .NET MAUI 仅允许发布 MSIX package。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM