dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 525 forks source link

error XARLP7000: Xamarin.Tools.Zip.ZipException: Renaming temporary file failed: No such file or directory #9321

Open jeromelaban opened 6 days ago

jeromelaban commented 6 days ago

Android framework version

net8.0-android

Affected platform version

.NET 8 - 34.0.138

Description

On macOS, building an android app may fail with the following:

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.138/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 989
   at Xamarin.Android.Tasks.ZipArchiveEx.Dispose(Boolean disposing)
   at Xamarin.Android.Tasks.ZipArchiveEx.Dispose()
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.<>c__DisplayClass75_0.<CreateResourceArchive>b__0(String f)
   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 92
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.CreateResourceArchive(String resDir, String outputFile)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask()
   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 [/Users/stephenhauck/Documents/GitHub/Uno.Samples/reference/SimpleCalc/CSharp-MVUX/SimpleCalculator/SimpleCalculator.csproj]

Steps to Reproduce

Build this solution: https://github.com/unoplatform/Uno.Samples/tree/master/reference/SimpleCalc/CSharp-MVUX.

It may work or fail randomly. This was reported by a user, I could not reproduce myself.

Did you find any workaround?

Rebuilding, maybe?

Relevant log output

The original binlog: https://github.com/unoplatform/uno/discussions/18192#discussioncomment-10742232

jonathanpeppers commented 6 days ago

Hmm, <ResolveLibraryProjectImports/> should be opening a .zip file in "readonly" mode. Should it use a temp file at all for that case?

Then I saw:

https://github.com/dotnet/android/blob/8bb3c8ec0ae832e0dbe5dbc0bb5d357916ba8de5/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs#L455-L463

Added for special chars in:

We could maybe do something for this case, but other .zip files could hit the same issue? It could also happen when writing an .apk. /cc @dellis1972 @grendello

dellis1972 commented 6 days ago

I've seen this when the OS runs out of file handles. I had to change the ulimit to be unlimited to work around it.