Repository navigation
Build errors after cleaning bin/obj #10124
Copy link
Copy link
Closed
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.
Milestone
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.
Activity
jonathanpeppers commentedon May 8, 2025
Can you get a
.binlog? Once it fails like that try a command-line build:And share the
.binloghere.It probably doesn't matter if you have .NET 10, the build tasks for
TargetFramework=net9.0-androidwould use our stable packages.SuperJMN commentedon Apr 22, 2026
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). SameXARDF7024/RemoveDirFixed/Directory not empty, intermittent, simply re-runningdotnet publishsucceeds.Repro
It reproduces reliably (~30–50% of runs) under the following conditions:
ntfs3driver on Linux (/dev/sdX on /mnt/... type ntfs3 (rw,relatime,uid=1000,gid=1000,force,iocharset=utf8)).dotnet publish -c Release -f net10.0-android -p:AndroidKeyStore=true ...from a tool / shell (not from VS / VS Code).obj/Release/net10.0-android/android/assets/<abi>(in my casearm64-v8a), exactly the pathRemoveDirFixedis trying to delete.Re-running
dotnet publishimmediately after the failure succeeds in nearly all cases. Manuallyrm -rf obj/Release/net10.0-android/androidbetween the two attempts makes the second run succeed 100% of the time in my testing.Likely amplifier: NTFS via ntfs3
I strongly suspect
ntfs3is 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 modeRemoveDirectoryRecursive-> "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 inRemoveDirFixed.If a maintainer wants to repro on Linux without dual-booting Windows, mounting any NTFS partition with
ntfs3and dropping a small Android project on it should be enough to flush the bug out fairly quickly.Stack trace (for the search engines)
Environment
linux-x64Microsoft.Android.Sdk.Linux36.1.53net10.0-androidntfs3driver (mountline above)dotnet publishfrom a CLI tool, single-m:1not enforcedWorkaround I've shipped in my deployment tool: detect
XARDF7024(orDirectory not empty+RemoveDirFixedin the output),rm -rf obj/Release/<tfm>/android, and retrydotnet publishonce. 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.
fix(android): retry once on transient XARDF7024 RemoveDirFixed race
jonathanpeppers commentedon Apr 22, 2026
@SuperJMN can your AI open a PR to fix it? It sounds confident. 😄
I would be ok to make
RemoveDirFixedjust warn if it can't delete a folder.SuperJMN commentedon Apr 23, 2026
Of course! Give me a minute ;D
Fixes dotnet#10124: retry RemoveDirFixed on ERROR_DIR_NOT_EMPTY
SuperJMN commentedon Apr 23, 2026
Update: PR up at #11195 — diagnosis turned out to be tiny and non-controversial.
TL;DR:
RemoveDirFixedalready retries with backoff, it just wasn't whitelistingERROR_DIR_NOT_EMPTY(0x80070091), which is what .NET mapsENOTEMPTYfromrmdir(2)to on Unix. Three lines: one new constant, one extra term in the existingif. 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
ntfs3mount or a refactor to injectDirectory.Delete, both of which felt heavy for a 3-line guardrail).[Xamarin.Android.Build.Tasks] Retry `<RemoveDirFixed/>` on `ERROR_DIR…