Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[One .NET] error with XA1030 for AOT and PublishTrimmed=false #7406

Merged
merged 2 commits into from
Sep 27, 2022

Conversation

jonathanpeppers
Copy link
Member

Fixes: #7178

Using this combination:

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

Causes apps to crash at runtime with:

07-18 11:39:53.613 20269 20269 D Mono    : AOT: module Microsoft.Maui.dll.so is unusable (GUID of dependent assembly Xamarin.AndroidX.AppCompat doesn't match (expected '1FC81757-8A70-4D56-93E6-8A635E2C23DE', got 'FD3821D1-CBF4-4956-B930-EA2A5379E18D')).

AOT runs right after the <ILLink/> MSBuild task, and so the combination currently doesn't work when trimming is disabled.

For now, to solve this let's emit a XA1030 error and fail the build. This way you at least get a reasonable error at build time instead of at runtime.

I do not know of a scenario when it would be useful to disable trimming completely during a Release + AOT build. If you are hitting a trimming/linker issue, you would be better off preserving a single assembly, type, etc.

Fixes: dotnet#7178

Using this combination:

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

Causes apps to crash at runtime with:

    07-18 11:39:53.613 20269 20269 D Mono    : AOT: module Microsoft.Maui.dll.so is unusable (GUID of dependent assembly Xamarin.AndroidX.AppCompat doesn't match (expected '1FC81757-8A70-4D56-93E6-8A635E2C23DE', got 'FD3821D1-CBF4-4956-B930-EA2A5379E18D')).

AOT runs right after the `<ILLink/>` MSBuild task, and so the
combination currently doesn't work when trimming is disabled.

For now, to solve this let's emit a `XA1030` error and fail the build.
This way you at least get a reasonable error at build time instead of
at runtime.

I do not know of a scenario when it would be useful to disable
trimming completely during a `Release` + AOT build. If you are hitting
a trimming/linker issue, you would be better off preserving a single
assembly, type, etc.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review September 27, 2022 13:55
@jonpryor jonpryor merged commit c331d75 into dotnet:main Sep 27, 2022
grendello added a commit to grendello/xamarin-android that referenced this pull request Sep 27, 2022
* main:
  [Xamarin.Android.Build.Tasks] XA1030 for AOT + PublishTrimmed=false (dotnet#7406)
jonathanpeppers added a commit that referenced this pull request Sep 27, 2022
…7406)

Fixes: #7178

Using this combination on .NET 6+:

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

Causes apps to crash at runtime with:

	D Mono    : AOT: module Microsoft.Maui.dll.so is unusable (GUID of dependent assembly Xamarin.AndroidX.AppCompat doesn't match (expected '1FC81757-8A70-4D56-93E6-8A635E2C23DE', got 'FD3821D1-CBF4-4956-B930-EA2A5379E18D')).

AOT runs right after the `<ILLink/>` MSBuild task, and so this
combination currently doesn't work when trimming is disabled.

For now, solve this by emitting an `XA1030` error and fail the build.
This way you at least get a reasonable error at build time instead of
at runtime.

I do not know of a scenario when it would be useful to disable
trimming completely during a `Release` + AOT build.  If you are
hitting a trimming/linker issue, you would be better off preserving
a single assembly, type, etc.
jonathanpeppers added a commit that referenced this pull request Sep 27, 2022
…7406)

Fixes: #7178

Using this combination on .NET 6+:

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

Causes apps to crash at runtime with:

	D Mono    : AOT: module Microsoft.Maui.dll.so is unusable (GUID of dependent assembly Xamarin.AndroidX.AppCompat doesn't match (expected '1FC81757-8A70-4D56-93E6-8A635E2C23DE', got 'FD3821D1-CBF4-4956-B930-EA2A5379E18D')).

AOT runs right after the `<ILLink/>` MSBuild task, and so this
combination currently doesn't work when trimming is disabled.

For now, solve this by emitting an `XA1030` error and fail the build.
This way you at least get a reasonable error at build time instead of
at runtime.

I do not know of a scenario when it would be useful to disable
trimming completely during a `Release` + AOT build.  If you are
hitting a trimming/linker issue, you would be better off preserving
a single assembly, type, etc.
@jonathanpeppers jonathanpeppers deleted the xa1030 branch September 27, 2022 18:48
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apps built with -c Release -p:PublishTrimmed=false crash at runtime, AOT + No trimmer
3 participants