Skip to content

[nativeaot] fix missing PreserveLists\*.xml files #9831

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

jonathanpeppers
Copy link
Member

A dotnet new maui project template fails to build with:

obj\Release\net10.0-android\android-arm64\android\src\mono\android\runtime\InputStreamAdapter.java:4: error: InputStreamAdapter is not abstract and does not override abstract method read() in InputStream
obj\Release\net10.0-android\android-arm64\android\src\mono\android\runtime\OutputStreamAdapter.java:4: error: OutputStreamAdapter is not abstract and does not override abstract method write(int) in OutputStream

I found I could also reproduce this issue with the BuildBasicApplicationAppCompat() MSBuild test.

After reviewing .binlog files, I found we weren't including PreserveLists\*.xml files at all in NativeAOT, as the Condition was false:

<_PreserveLists Include="$(MSBuildThisFileDirectory)..\PreserveLists\*.xml" />
<TrimmerRootDescriptor
    Condition=" '@(ResolvedFileToPublish->Count())' != '0' and '%(Filename)' != '' "
    Include="@(_PreserveLists)" />

9bc45b5 doesn't say why the Condition was added, but this was during early .NET 5 development. Some of this code may have been shared with Xamarin.Android back then.

We can simply remove the Condition to fix this, and the MSBuild test also passes.

@jonathanpeppers
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Context: 9bc45b5

A `dotnet new maui` project template fails to build with:

    obj\Release\net10.0-android\android-arm64\android\src\mono\android\runtime\InputStreamAdapter.java:4: error: InputStreamAdapter is not abstract and does not override abstract method read() in InputStream
    obj\Release\net10.0-android\android-arm64\android\src\mono\android\runtime\OutputStreamAdapter.java:4: error: OutputStreamAdapter is not abstract and does not override abstract method write(int) in OutputStream

I found I could also reproduce this issue with the
`BuildBasicApplicationAppCompat()` MSBuild test.

After reviewing `.binlog` files, I found we weren't including
`PreserveLists\*.xml` files *at all* in NativeAOT, as the `Condition`
was false:

    <_PreserveLists Include="$(MSBuildThisFileDirectory)..\PreserveLists\*.xml" />
    <TrimmerRootDescriptor
        Condition=" '@(ResolvedFileToPublish->Count())' != '0' and '%(Filename)' != '' "
        Include="@(_PreserveLists)" />

9bc45b5 doesn't say why the `Condition` was added, but this was
during early .NET 5 development. Some of this code may have been
shared with Xamarin.Android back then.

We can simply remove the `Condition` to fix this, and the MSBuild test
also passes.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/NativeAOTPreserve branch from 5d45fad to 8b95494 Compare February 24, 2025 18:27
@jonathanpeppers jonathanpeppers marked this pull request as ready for review February 24, 2025 18:28
@jonathanpeppers
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dellis1972 dellis1972 merged commit 2dd6f32 into main Feb 25, 2025
59 checks passed
@dellis1972 dellis1972 deleted the dev/peppers/NativeAOTPreserve branch February 25, 2025 14:28
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants