为什么 MAUI 应用可以调试但发布失败

huangapple go评论105阅读模式
英文:

Why MAUI App can Debug but Release failed

问题

我已经构建了一个Maui应用程序。在Android设备上调试正常,但启动速度较慢,因此我尝试了发布(优化以加快启动速度,如果您有其他方法来优化启动速度,请在此处告诉我),而不是调试,但失败了。

以下是日志:

错误		NETSDK1144:优化程序集大小失败。可以通过将PublishTrimmed属性设置为false来禁用优化。		 	0	

错误		IL1032:无法找到根程序集'obj\Release\net7.0-android\MerciDistribuzione.dll'。		 	0	
英文:

I Have built a Maui app. It debug well in Android device, but it slow start so I try Release (optimize to speed up startup,if you have another method for optimize to speed up startup tell me here) instead of Debug, but it failed.

here are logs:

Severity	Code	Description	Project	File	Line	Suppression State
Error		NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.		 	0	

Severity	Code	Description	Project	File	Line	Suppression State
Error		IL1032: Root assembly 'obj\Release\net7.0-android\MerciDistribuzione.dll' could not be found.		 	0	

答案1

得分: 0

从调试到发布构建的 MAUI 应用,应用程序的启动速度显著提高,我的大约是 3/4 秒。

步骤 1:选择发布(Release)而不是调试(Debug)。

步骤 2:在“生成”菜单栏下选择“配置管理器”,选择发布,同时选择相应的生成和部署选项。

步骤 3:双击项目(解决方案下的主项目)进入项目配置文件,添加以下内容:

<PropertyGroup>
    <PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

(请注意,此添加的 PropertyGroup 仅用于发布启动运行。如果您想要稍后进行调试启动运行,必须在项目配置文件中删除此 PublishTrimmed PropertyGroup。)

步骤 4:在工具下,在 NuGet 包管理器中,已经下载到项目的包,删除不需要的未使用的包(您可以打开一个全新的 Muai APP1,它是 Microsoft 的默认状态,打开 NuGet,比较哪些包已添加到您的项目中,然后查看自己的代码以确定哪些是需要的。删除未使用的包),然后开始运行(建议首先删除 bin 和 obj,然后运行)。

英文:

From debug to Release build maui app, the startup speed of the app is significantly increased, mine is about 3/4 seconds.

Step 1: select Release instead of Debug.

Step 2: select the !configuration manager!! under the 'Build' menu bar, select release, the corresponding Build and Deploy Checked both.

Step 3: Double-click the project (the main project under the solution) to enter the project configuration file, add

&lt;PropertyGroup &gt;
   &lt;PublishTrimmed&gt;true &lt;/PublishTrimmed&gt;
&lt;/PropertyGroup &gt;

(Remember, this added PropertyGroup is only for Release start run. If you want to Debug start run later, you must delete this PublishTrimmed PropertyGroup in the project configuration file.)

Step 4: under the tool, in the Nuget package manager, it has been downloaded to the project, and Delete unnecessary packages that are not used (you can open a brand new Muai APP1, which is in the default state of Microsoft, open Nuget, compare which packages are added to your project, and then look at your own code to see which ones are needed. Delete the unused ones), start running (it is recommended to delete bin and obj first, and then run)

huangapple
  • 本文由 发表于 2023年6月29日 19:08:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580474.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定