Skip to content

[AOT] Failure when the path to the temp folder contains accentuated characters and/or spaces #9523

Open

Description

@jeromelaban

Android framework version

net8.0-android

Affected platform version

8.0.11

Description

On Windows, when building with AOT enabled, and the user home folder has an accentuated character and/or a space, the build fails with:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.145\targets\Microsoft.Android.Sdk.Aot.targets(109,5): Precompiling failed for E:\Net2022files\WinNavUno5\WinNavUno5\obj\Release\net8.0-android\android-x64\linked\_Microsoft.Android.Resource.Designer.dll with exit code 1.
The specified response file can not be read [E:\Net2022files\WinNavUno5\WinNavUno5\WinNavUno5.csproj]

Steps to Reproduce

Build an app with AOT enabled, with a user folder with accentuated characters and/or spaces.

Did you find any workaround?

Changing the user folder path to be without spaces and accentuated characters.

Relevant log output

binlog (14).zip

Activity

  1. dellis1972 commented on Nov 18, 2024

    @dellis1972
    Contributor

    @jeromelaban very odd. So the temp folder path has an accented character in it :(

    @akoeplinger any idea who works on the \mono-aot-cross.exe ? Looks like an issue in that area.

    [WinNavUno5.dll] Running: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64\8.0.11\Sdk\..\tools\mono-aot-cross.exe --response="C:\Users\Werner König\AppData\Local\Temp\tmp12E0.tmp"
    
  2. jeromelaban commented on Nov 18, 2024

    @jeromelaban
    Author

    It is odd indeed.

    I noticed this particular behavior when accounts are created using MS Entra Online-only (Azure AD) accounts, where the tooling does not "normalize" the folder to 7-bits ASCII and uses the user's original name instead of the SAMAccount field.

    My own name has an accent in it, and it's also causing all sorts of issues which I avoid by changing the folder from the get-go...

  3. akoeplinger commented on Nov 19, 2024

    @akoeplinger
    Member

    would you mind trying with dotnet 9? there were some related fixes in that area.

  4. jonathanpeppers commented on Jul 11, 2025

    @jonathanpeppers
    Member

    Let us know if this is still happening in .NET 9, thanks.

  5. jeromelaban commented on Jul 15, 2025

    @jeromelaban
    Author

    @jonathanpeppers it's definitely still happening, with an earlier error now:

    Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Aapt2.targets(214,3): error APT2264: The system cannot find the file specified. (2): D:\temp\Issue9532\MauiApp4_with_é\obj\Debug\net9.0-android\assets.
    This could be caused by the project exceeding the Windows maximum path length limitation. 
    See https://learn.microsoft.com/dotnet/android/messages/apt2264 for details.
    [D:\temp\Issue9532\MauiApp4_with_é\MauiApp4.csproj]
    

    Issue9532.zip

  6. added
    need-attentionA xamarin-android contributor needs to review
    and removed
    need-infoIssues that need more information from the author.
    on Jul 15, 2025
  7. dellis1972 commented on Jul 15, 2025

    @dellis1972
    Contributor

    @jonathanpeppers it's definitely still happening, with an earlier error now:

    Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Aapt2.targets(214,3): error APT2264: The system cannot find the file specified. (2): D:\temp\Issue9532\MauiApp4_with_é\obj\Debug\net9.0-android\assets.
    This could be caused by the project exceeding the Windows maximum path length limitation. 
    See https://learn.microsoft.com/dotnet/android/messages/apt2264 for details.
    [D:\temp\Issue9532\MauiApp4_with_é\MauiApp4.csproj]
    

    Issue9532.zip

    That is a bug in aapt2 its not something we can deal with unfortunately, without getting in a fixing aapt2 :(

  8. akoeplinger commented on Jul 21, 2025

    @akoeplinger
    Member

    77a6606 would've probably caused a more appropriate build error in net10.

    That said, I tried manually running the aapt2.exe command and if I replace the non-ascii path in the -A option with just a relative path then the command works (even though other arguments contain the non-ascii path), and if I build again after that everything works and I get an .apk.

    @dellis1972 @jonathanpeppers Maybe a workaround would be to calculate a relative path for passing to the -A option?

  9. dellis1972 commented on Jul 21, 2025

    @dellis1972
    Contributor

    @dellis1972 @jonathanpeppers Maybe a workaround would be to calculate a relative path for passing to the -A option?

    We can't. The aapt2 is run as a daemon for faster resource processing. This has to be done in the temp directory otherwise it messes with Visual Studio (it thinks the directory/files are locked). So we have to pass ALL paths as full paths to the aapt2 process.

    We only run up the aapt2 for the build, so it doesn't hang around, but VS still has issues it seemed.

  10. akoeplinger commented on Jul 21, 2025

    @akoeplinger
    Member

    Ah okay, interesting. Maybe we could copy the assets directories to the temp directory and delete them after aapt2 is done (for non-ascii paths).

    Or is it possible to disable the the daemon mode for aapt2 if we detect non-ascii paths?

  11. dellis1972 commented on Jul 21, 2025

    @dellis1972
    Contributor

    Ah okay, interesting. Maybe we could copy the assets directories to the temp directory and delete them after aapt2 is done (for non-ascii paths).

    The problem with that is people tend to put large files in assets, we don't really want to be copying them around unless we really have to.

    Or is it possible to disable the the daemon mode for aapt2 if we detect non-ascii paths?

    Its not really setup that way unfortunately

    This is the code https://github.com/dotnet/android/blob/main/src/Xamarin.Android.Build.Tasks/Utilities/Aapt2Daemon.cs.

    We could possibly try putting the working directory in obj again, things might have changed in VS with the new project system.

  12. beeradmoore commented on Oct 21, 2026

    @beeradmoore

    @jonathanpeppers , this is still happening with .NET 10. On top of that if you use dotnetup in its default config (at least on macOS) it will also cause this problem as it installs to /Users/{user}/Library/Application Support/dotnetup/. I don't know if there is someone on that team to ping about possibly changing the default config to ~/.dotnetup/dotnetup or if the resolution needed is with fixing something in net-android.

    Repro goes as such.

    Install dotnet into ~/dotnet up/ (custom path just to replicate later that custom paths do work).

    cd ~
    mkdir "dotnet up"
    dotnetup init --install-path "/Users/{user}/dotnet up"
    

    Reload terminal. I found I just had to create a new tab, source ~/.zprofile didn't work and I don't recall the zsh command to reload shell.

    Create new folder, install android workloads, build for release.

    mkdir dotnetupandroidtest 
    cd dotnetupandroidtest
    dotnet workload install android
    dotnet new android
    dotnet build -c Release
    

    Errors with 16 errors of "Precompiling failed for", 4 for each arch.

    Cleanup

    cd ~
    rm -rf "dotnet up"
    rm -rf "dotnetupandroidtest"
    

    Trying again but with a better setup directory with no space.

    cd ~
    mkdir "dotnetup"
    dotnetup init --install-path "/Users/{user}/dotnetup"
    

    reload terminal

    mkdir dotnetupandroidtest 
    cd dotnetupandroidtest
    dotnet workload install android
    dotnet new android
    dotnet build -c Release
    

    This one works fine because there is no space in the dotnet path.

  13. jonathanpeppers commented on Oct 21, 2026

    @jonathanpeppers
    Member

    @beeradmoore have you had more success with .NET 11?

    The issue here is in dotnet/runtime's Mono AOT compiler, which is not going to be used anymore going forward.

    CoreCLR will use ReadyToRun instead, which is completely different.

  14. beeradmoore commented on Oct 21, 2026

    @beeradmoore

    I have not tried .NET 11 at all unfortunately. Thanks to dotnetup though and the ability to nuke dotnet from my system (if something bad happens) and re-add it within minutes I will certainly try. I'll get back to you.

  15. beeradmoore commented on Oct 27, 2026

    @beeradmoore

    I cleared my system of dotnet, did dotnetup init and installed latest preview in default directory, then did the same think to make a blank Android app. That built the app fine 👍

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

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.need-attentionA xamarin-android contributor needs to review

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions