[Xamarin.Android.Build.Tasks] fix Debug mode and $(PublishTrimmed) by jonathanpeppers · Pull Request #9452 · dotnet/android (original) (raw)

There is a problem if you have the combination:

We emit an XA0119 warning with this combination, as there is not a good reason to do it.

But unfortunately, the build will be completely broken as all the .NET assemblies don't make it to the .apk! I could reproduce this in a test.

The fix is that the logic in the <ProcessAssemblies/> MSBuild task:

if (PublishTrimmed && !AndroidIncludeDebugSymbols) {
    //...
    ShrunkAssemblies = shrunkAssemblies.ToArray ();
}

Has a case, where we did not fill out the ShrunkAssemblies [Output] item group:

if (!AndroidIncludeDebugSymbols) {
    // existing logic...
} else {
    ShrunkAssemblies = OutputAssemblies;
}

Going forward, we could probably refactor some of this logic to make things simpler, but this is a reasonable fix for now.