Skip to content

Build errors after cleaning bin/obj #10124

Closed

Description

@davidortinau

Android framework version

net9.0-android

Affected platform version

VS Code, .NET 10 P3, TFM is net9.0-android

Description

I see other reports of some of these errors like #9321

I can repeat this pretty reliably by deleting the bin/obj and hitting F5 from VS Code on macOS.

You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  Telepathic net9.0-android failed with 1 error(s) (4.3s)
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.61/tools/Xamarin.Android.EmbeddedResource.targets(39,5): 

error XARLP7000: Xamarin.Tools.Zip.ZipException: Renaming temporary file failed: No such file or directory
at Xamarin.Tools.Zip.ZipArchive.Close() in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:line 991
at Xamarin.Android.Tasks.ZipArchiveEx.Dispose(Boolean disposing) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ZipArchiveEx.cs:line 232
at Xamarin.Android.Tasks.ZipArchiveEx.Dispose() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ZipArchiveEx.cs:line 225
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.<>c__DisplayClass81_0.<CreateResourceArchive>b__0(String f) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 514
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.<>c__DisplayClass81_0.<CreateResourceArchive>b__0(String f) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 512
at Microsoft.Android.Build.Tasks.Files.ArchiveZipUpdate(String target, Action`1 archiver) in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 137
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.CreateResourceArchive(String resDir, String outputFile) in/Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 511
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles, ICollection`1 extractedDirectories) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 479
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 106
at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25

Build failed with 1 error(s) in 4.4s

 *  The terminal process "/bin/zsh '-l', '-c', 'dotnet build -t:Run -p:Configuration=Debug -f net9.0-android -p:AdbTarget=-s%20emulator-5554 -p:AndroidAttachDebugger=true -p:AndroidSdbTargetPort=63536 -p:AndroidSdbHostPort=63536 -p:CustomAfterMicrosoftCSharpTargets="/Users/davidortinau/.vscode-insiders/extensions/ms-dotnettools.dotnet-maui-1.10.16-darwin-arm64/dist/resources/Custom.After.Microsoft.CSharp.targets" -p:MauiVSCodeBuildOutputFile="/var/folders/qn/w9562c_n0kq36zc8lqtg_yzh0000gn/T/dotnet-maui/maui-vsc-d138a987-169d-4ffe-8c49-96ba42e03f68.json" -p:AndroidSdkDirectory="/Users/davidortinau/Library/Android/sdk" -p:JavaSdkDirectory="/Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home" -p:XamlTools="/Users/davidortinau/.vscode-insiders/extensions/ms-dotnettools.csharp-2.74.24-darwin-arm64/.xamlTools" /Users/davidortinau/work/dotnet-buildai/src/Telepathic/Telepathic.csproj'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

Build for iOS. Delete Bin/Obj. Build for Android.

Telepathic net9.0-android failed with 1 error(s) (1.2s)
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.61/tools/Xamarin.Android.Common.targets(2661,2): error XARDF7024: 
      System.IO.IOException: Directory not empty : '/Users/davidortinau/work/dotnet-buildai/src/Telepathic/obj/Debug/net9
      .0-android/lp/147/jl'
         at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath)
         at Xamarin.Android.Tasks.RemoveDirFixed.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.
      Build.Tasks/Tasks/RemoveDirFixed.cs:line 66

Build failed with 1 error(s) in 1.4s

 *  The terminal process "/bin/zsh '-l', '-c', 'dotnet build -t:Run -p:Configuration=Debug -f net9.0-android -p:AdbTarget=-s%20emulator-5554 -p:AndroidAttachDebugger=true -p:AndroidSdbTargetPort=50024 -p:AndroidSdbHostPort=50024 -p:CustomAfterMicrosoftCSharpTargets="/Users/davidortinau/.vscode-insiders/extensions/ms-dotnettools.dotnet-maui-1.10.16-darwin-arm64/dist/resources/Custom.After.Microsoft.CSharp.targets" -p:MauiVSCodeBuildOutputFile="/var/folders/qn/w9562c_n0kq36zc8lqtg_yzh0000gn/T/dotnet-maui/maui-vsc-0a92e09d-b2f0-4d57-be62-06ccab4a452f.json" -p:AndroidSdkDirectory="/Users/davidortinau/Library/Android/sdk" -p:JavaSdkDirectory="/Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home" -p:XamlTools="/Users/davidortinau/.vscode-insiders/extensions/ms-dotnettools.csharp-2.74.24-darwin-arm64/.xamlTools" /Users/davidortinau/work/dotnet-buildai/src/Telepathic/Telepathic.csproj'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

I'm also on macOS 15.4.1, M4 Max

Steps to Reproduce

Some combo of:

Build for a non-Android platform
Clean bin/obj
Build for Android
Observe some error
F5 again without changing anything and succeed.

Did you find any workaround?

No response

Relevant log output

Activity

  1. jonathanpeppers commented on May 8, 2025

    @jonathanpeppers
    Member

    Can you get a .binlog? Once it fails like that try a command-line build:

    dotnet build -t:Run -f net9.0-android -bl
    

    And share the .binlog here.

    It probably doesn't matter if you have .NET 10, the build tasks for TargetFramework=net9.0-android would use our stable packages.

  2. SuperJMN commented on Apr 22, 2026

    @SuperJMN
    Contributor

    Confirming I'm hitting this on Linux (CLI, no IDE involved) with .NET 10.0.201 + Android SDK 36.1.53 (TFM net10.0-android). Same XARDF7024 / RemoveDirFixed / Directory not empty, intermittent, simply re-running dotnet publish succeeds.

    Repro

    It reproduces reliably (~30–50% of runs) under the following conditions:

    1. Repo lives on an NTFS volume mounted with the kernel ntfs3 driver on Linux (/dev/sdX on /mnt/... type ntfs3 (rw,relatime,uid=1000,gid=1000,force,iocharset=utf8)).
    2. Run dotnet publish -c Release -f net10.0-android -p:AndroidKeyStore=true ... from a tool / shell (not from VS / VS Code).
    3. The failure points at obj/Release/net10.0-android/android/assets/<abi> (in my case arm64-v8a), exactly the path RemoveDirFixed is trying to delete.

    Re-running dotnet publish immediately after the failure succeeds in nearly all cases. Manually rm -rf obj/Release/net10.0-android/android between the two attempts makes the second run succeed 100% of the time in my testing.

    Likely amplifier: NTFS via ntfs3

    I strongly suspect ntfs3 is amplifying an existing race rather than being the root cause. NTFS directory metadata updates aren't POSIX-equivalent: a directory can momentarily report children that have just been unlinked, which is exactly the failure mode RemoveDirectoryRecursive -> "Directory not empty" exhibits here. I have not been able to reproduce it on the same machine when the repo lives on an ext4 partition, only on the NTFS one — so this looks like a "scale-up" repro for whatever timing window already exists in RemoveDirFixed.

    If a maintainer wants to repro on Linux without dual-booting Windows, mounting any NTFS partition with ntfs3 and dropping a small Android project on it should be enough to flush the bug out fairly quickly.

    Stack trace (for the search engines)

    error XARDF7024: System.IO.IOException: Directory not empty : '.../obj/Release/net10.0-android/android/assets/arm64-v8a'
       at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath)
       at Xamarin.Android.Tasks.RemoveDirFixed.RunTask()
    

    Environment

    • OS: Pop!_OS 24.04 LTS, kernel 6.18.7, x86_64
    • .NET SDK: 10.0.201 (runtime 10.0.5), linux-x64
    • Workload pack: Microsoft.Android.Sdk.Linux 36.1.53
    • TFM: net10.0-android
    • Filesystem: NTFS via kernel ntfs3 driver (mount line above)
    • Invocation: programmatic dotnet publish from a CLI tool, single -m:1 not enforced

    Workaround I've shipped in my deployment tool: detect XARDF7024 (or Directory not empty + RemoveDirFixed in the output), rm -rf obj/Release/<tfm>/android, and retry dotnet publish once. Unblocks our CI without any user-visible impact, but it's clearly a band-aid for an upstream race.

    Happy to gather strace / inotify traces of a failing run if that would help triage.

  3. jonathanpeppers commented on Apr 22, 2026

    @jonathanpeppers
    Member

    @SuperJMN can your AI open a PR to fix it? It sounds confident. 😄

    I would be ok to make RemoveDirFixed just warn if it can't delete a folder.

  4. SuperJMN commented on Apr 23, 2026

    @SuperJMN
    Contributor

    @SuperJMN can your AI open a PR to fix it? It sounds confident. 😄

    I would be ok to make RemoveDirFixed just warn if it can't delete a folder.

    Of course! Give me a minute ;D

  5. added a commit that references this issue on Apr 23, 2026
    ca4bdd3
  6. SuperJMN commented on Apr 23, 2026

    @SuperJMN
    Contributor

    Update: PR up at #11195 — diagnosis turned out to be tiny and non-controversial.

    TL;DR: RemoveDirFixed already retries with backoff, it just wasn't whitelisting ERROR_DIR_NOT_EMPTY (0x80070091), which is what .NET maps ENOTEMPTY from rmdir(2) to on Unix. Three lines: one new constant, one extra term in the existing if. No change in behavior once retries are exhausted.

    Ball's in your court @jonathanpeppers — happy to add a test if you want one (didn't add one because the only honest deterministic repro needs an ntfs3 mount or a refactor to inject Directory.Delete, both of which felt heavy for a 3-line guardrail).

  7. locked and limited conversation to collaborators on May 24, 2026
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.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions