適用於 Android 的 .NET 警告 XA1029

範例訊息

warning XA1029: The 'AotAssemblies' MSBuild property is deprecated. Edit the project file in a text editor to remove this property, and use the 'RunAOTCompilation' MSBuild property instead.

Issue

每當指定 $(AotAssemblies) 時,都會發出此警告,包括將其設為 false 時也是如此。

解決方法

對於使用 Mono 的受支援 .NET 10 與更早版本專案,請勿使用下列方式:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <AotAssemblies>true</AotAssemblies>
</PropertyGroup>

請改用:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

對於 CoreCLR 或 NativeAOT 專案,請移除 $(AotAssemblies) 但不加 $(RunAOTCompilation)。 這些執行階段不使用 Mono AOT 管線。 如果 $(AotAssemblies) 為 true,而 $(RunAOTCompilation) 未設定或為 true,轉發會產生會導致建置停止的 XA1044 錯誤。