Leo*_*sen 15 .net c# publish visual-studio maui
如何将 .net MAUI 应用程序发布为单个可执行文件?这可能吗?我有一个应用程序,希望我的朋友在他们的 Windows PC 上使用。有什么办法不使用命令提示符吗?
Ing*_*ngo 22
使用新版本的 .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
Run Code Online (Sandbox Code Playgroud)
或者如果您想将某些旧系统的目标定为 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
Run Code Online (Sandbox Code Playgroud)
构建 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=x64 /p:PublishSingleFile=true /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64
Run Code Online (Sandbox Code Playgroud)
构建exe(x64)文件可以在\bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish\中找到
1- 将<WindowsPackageType>
节点添加到 .NET MAUI csproj 文件:
<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>
Run Code Online (Sandbox Code Playgroud)
2-在你的launchSettings.json中设置commandName
为Project
Release
3- 在模式下构建您的项目
4-右键单击项目 -> 在文件资源管理器中打开文件夹
5- exe文件位于:bin -> Release -> net7.0-windows10.0.19041.0 -> win10-x64
归档时间: |
|
查看次数: |
9988 次 |
最近记录: |