【问题标题】:Publish .net MAUI Application as windows executable将 .net MAUI 应用程序发布为 Windows 可执行文件
【发布时间】:2022-06-29 22:24:52
【问题描述】:

如何将 .net MAUI 应用程序发布到单个可执行文件?这甚至可能吗? 我有一个应用程序,我希望我的朋友在他们的 Windows PC 上使用它。不使用命令提示符有什么办法吗?

【问题讨论】:

  • 如果是 UWP 应用,那么你应该可以使用正常的 UWP 发布选项
  • 或者如果它是一个“Windows 桌面”应用程序,答案是MSIX Packaging Tool。我还没有尝试过 - 你可能会遇到问题,因为 VS 2022 Preview 和 MAUI 都是 .. Preview。

标签: c# .net visual-studio publish maui


【解决方案1】:

使用新版本的 .net MAUI 6.0.400(服务版本 1),您可以将应用程序构建为可工作的 exe 文件。

在 Visual Studio 中: 右键单击您的解决方案,在终端中打开。 运行以下命令:

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

或者如果您想将 x86 用于某些旧系统:

msbuild /restore /t:build /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x86 /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x86

构建 exe (x64) 文件位于 \bin\x64\release\net6.0-windows10.0.19041\win10-x64


发布到单个文件是可能的,但目前有点错误,例如图像需要从构建文件夹复制到发布文件夹才能工作。但是,通过 Blazor 在 wwwroot 文件夹中使用的图像可以正常工作。
发布命令:

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

build exe (x64) 文件位于\bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish\

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    相关资源
    最近更新 更多