Skip to content

Error NETSDK1144: Optimizing assemblies for size failed #117153

@williambuchanan2

Description

@williambuchanan2

Description

Last night the builds just started failing - we hadn’t made any obvious changes which would affect it. It is failing on the dotnet publish step.

dotnet publish $(solutionName) -f net9.0-android

It fails running dotnet publish on my PC as well, although the build works fine in VS.

The error is below (same for Android and iOS except for the code):

C:\Users\VssAdministrator.nuget\packages\microsoft.net.illink.tasks\9.0.6\build\Microsoft.NET.ILLink.targets(96,5): error NETSDK1144: Optimizing assemblies for size failed. [D:\a\1\s\NetCore\Client\PDSX\PDS.App.PDSX.csproj::TargetFramework=net9.0-android]

I have discovered the problem.

The build is failing because of the 'where' line of code below. With that code in place the build fails. If I remove that line of code the build succeeds.

var modalStack = Application.Current?.Windows[0].Navigation.ModalStack;

if (modalStack.Any())
{
    await Application.Current.Dispatcher.DispatchAsync(async () =>
    {
        var navigation = Application.Current?.Windows[0].Navigation;

        while (navigation.ModalStack.Any(page => page is TPage)) // <- THIS IS THE PROBLEM
        {
            // Find the topmost TPage and pop it
            for (int i = navigation.ModalStack.Count - 1; i >= 0; i--)
            {
                if (navigation.ModalStack[i] is TPage)
                {
                    await navigation.PopModalAsync(false);
                    await Task.Delay(300);
                    break;
                }
            }
        }
    });
}

Steps to Reproduce

Insert above code
Execute dotnet publish command

Link to public reproduction project repository

N/A

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.70 SR7

Affected platforms

iOS, Android

Affected platform versions

Android, ios

Did you find any workaround?

No

Relevant log output

Android:

C:\Users\VssAdministrator.nuget\packages\microsoft.net.illink.tasks\9.0.6\build\Microsoft.NET.ILLink.targets(143,5): error MSB6006: “dotnet.exe” exited with code -1073741571. [D:\a\1\s\NetCore\Client\PDSX\PDS.App.PDSX.csproj::TargetFramework=net9.0-android]
C:\Users\VssAdministrator.nuget\packages\microsoft.net.illink.tasks\9.0.6\build\Microsoft.NET.ILLink.targets(96,5): error NETSDK1144: Optimizing assemblies for size failed. [D:\a\1\s\NetCore\Client\PDSX\PDS.App.PDSX.csproj::TargetFramework=net9.0-android]

iOS:
/Users/runner/.nuget/packages/microsoft.net.illink.tasks/9.0.6/build/Microsoft.NET.ILLink.targets(143,5): error MSB6006: "dotnet" exited with code 134. [/Users/runner/work/1/s/NetCore/Client/PDSX/PDS.App.PDSX.csproj::TargetFramework=net9.0-ios]
/Users/runner/.nuget/packages/microsoft.net.illink.tasks/9.0.6/build/Microsoft.NET.ILLink.targets(96,5): error NETSDK1144: Optimizing assemblies for size failed. [/Users/runner/work/1/s/NetCore/Client/PDSX/PDS.App.PDSX.csproj::TargetFramework=net9.0-ios]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Tools-ILLink.NET linker development as well as trimming analyzers

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions