Skip to content

[msbuild] Cached AOT compiler path not always invalidated after .NET upgrade #25481

Closed

Description

@jifryk

Description

replacing issue# 35446 in the hopes of getting more attention on this issue


Similar to issue# 20918, or maybe issue# 17340, BUT 20918 doesn't seem to have a final resolution, and the ILLink package ref'd in 17340 solution is not included in our project.

We published our maui app to Google Play and Apple App stores back in December, now we're looking to do an update.

When building for iOS, we built our new code using the same environment used for December build just fine, but when we tried to upload to TestFlight, we ran into the updated requirement where we must now build with iOS 26 SDK (we were using iOS 18.5 SDK); we upgraded to XCode 26 and have iOS 26.2 platform available.

Now, when we try to build for iOS we get the following error:

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_26.2/26.2.9008/targets/Xamarin.Shared.Sdk.targets(1387,3): error MSB4018: 
      The "AOTCompile" task failed unexpectedly.
System.AggregateException: One or more errors occurred. (One or more errors occurred. (One or more errors occurre
      d. (An error occurred trying to start process '/usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.os
      x-arm64.Cross.ios-arm64/9.0.9/Sdk/../tools/mono-aot-cross' with working directory '/Users/xinjundong/Documents/is
      can-mobile/Apps/IScanBT'. No such file or directory)))

...indeed, the ref'd 9.0.9 version is not installed, we have 9.0.15 instead.

Need some guidance on (presumably) changing some config file or parameter to point to the correct version, or some other workaround for this issue.


What we tried:

  • cleared NuGet cache- still fails
  • set PublishAOT = false in csproj- still fails
  • search for 9.0.9 refs in project and platform build artifacts- not found
  • copied 9.0.15 version to 9.0.9 path ref'd in error message; the build completes but we're getting weird layout issues that we don't see in the equivalent Android build from the same source (this is obviously extremely hacky- I didn't expect the build to work and not surprised the runtime has issues)

re regression question below- it arguably is or is not a regression, depending on your perspective (thus the conflicting answer x2), but I assume it's really just a config issue

Steps to Reproduce

  1. Have an existing working app and working iOS build process utilizing XCode + iOS 18.5 SDK
  2. Upgrade to XCode 26 + iOS 26.2 SDK
  3. Attempt to build with dotnet cli
  4. The build fails with error ref'ing /dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.os
    x-arm64.Cross.ios-arm64/9.0.9/ path, we have */9.0.15/ instead

Link to public reproduction project repository

No response

Version with bug

9.0.100 SR10

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, No, this is something new

Last version that worked well

9.0.100 SR10

Affected platforms

iOS

Affected platform versions

iOS 26.2 SDK (build error after upgrading XCode + iOS from 18.5 SDK, which worked fine); dotnet workload list refs Manifest Version=9.0.120/9.0.100 & Installation Source=SDK 9.0.300 for both Android & iOS

Did you find any workaround?

No

Relevant log output

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_26.2/26.2.9008/targets/Xamarin.Shared.Sdk.targets(1387,3): error MSB4018: 
      The "AOTCompile" task failed unexpectedly.
System.AggregateException: One or more errors occurred. (One or more errors occurred. (One or more errors occurred. (An error occurred trying to start process '/usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.9/Sdk/../tools/mono-aot-cross' with working directory '/Users/xinjundong/Documents/iscan-mobile/Apps/IScanBT'. No such file or directory)))

## ...indeed, the ref'd 9.0.9 version is not installed, we have 9.0.15 instead. ##

Activity

  1. PureWeen commented on May 19, 2026

    @PureWeen
    Member
  2. transferred this issue fromdotnet/mauion May 20, 2026
  3. rolfbjarne commented on May 20, 2026

    @rolfbjarne
    Member

    Could you get the following information?

    1. The output from running dotnet --info
    2. A binary build log (binlog); this can be obtained by adding '-bl:msbuild.binlog' to the 'dotnet build/publish' command, and then uploading the msbuild.binlog file here (note that you'll have to zip the file first, otherwise GitHub will reject the upload). See https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#binary-build-logs for more information.

    Thanks!

  4. added
    need-info
    on May 20, 2026
  5. added this to the Future milestone on May 20, 2026
  6. jifryk commented on May 20, 2026

    @jifryk
    Author

    I should've mentioned- we did a dotnet workload update yesterday; retrying the build after, we got the following:

    /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_26.5/26.5.9001/targets/Xamarin.Shared.Sdk.targets(2346,3): error : This version of .NET for iOS (26.5.9001) requires Xcode 26.5. The current version of Xcode is 26.3. Either install Xcode 26.5, or use a different version of .NET for iOS.
    

    ...so installed Xcode 26.5, retrying the build again after that failed with the same original error

  7. added
    need-attention
    and removed
    need-info
    on May 20, 2026
  8. rolfbjarne commented on May 20, 2026

    @rolfbjarne
    Member

    Can you try deleting this file (relative to the project directory) and see if that fixes anything?

    obj/Release/net9.0-ios/ios-arm64/aot-compiler-path-9.0.305.txt

  9. jifryk commented on May 20, 2026

    @jifryk
    Author

    it appears that addressed our issue- I'm being told the build now completes successfully, will have absolute confirmation tomorrow

  10. rolfbjarne commented on May 22, 2026

    @rolfbjarne
    Member

    OK; I'll keep this open since it seems we have a caching/incremental builds issue we need to fix here.

  11. added
    bug
    msbuild
    and removed
    need-attention
    on May 22, 2026
  12. changed the title [-]Getting "The AOTCompile task failed unexpectedly." when trying to build for iOS after upgrade to iOS 26.2 SDK, it's referencing a different version of AOT ios arm64 pack than what's installed[/-] [+][msbuild] Cached AOT compiler path not always invalidated after .NET upgrade[/+] on May 22, 2026
  13. added theissue type on May 22, 2026
  14. jifryk commented on May 22, 2026

    @jifryk
    Author

    Sorry I didn't get back to this yesterday- I can absolutely confirm we're now able to build and distribute thru TestFlight.

    We discovered another cosmetic issue that wasn't occurring under the older iOS SDK and doesn't happen on Android. I am pretty sure this is something we're doing wrong in the xaml, but interesting that the rendering changed. I am planning to log another ticket next week on that once I get arms around it mostly as an FYI in case someone else bumps into it.

    We're all set on this topic, I'll leave this ticket for you to manage going forward with the refined title.

  15. rolfbjarne commented on Oct 20, 2026

    @rolfbjarne
    Member

    Closing, this will be fixed in .NET 11 (because we're not using the Mono AOT compiler anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmsbuild

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions