Closed dellis1972 closed 1 month ago
Fixes https://github.com/dotnet/android/issues/9133
Context: https://github.com/dotnet/android-tools/commit/60fae1924e2d71f31dc1ed05f7346fd7874d6636
Much to our chagrin, in .NET 6+ it is possible for Design-Time Builds
(DTBs) to run concurrently with "normal" builds, as there is nothing
within the [.NET Project System][0] or [Common Project System (CPS)][1]
which would actively *prevent* such concurrency.
Consequently, it is possible to encounter locked files and
directories during the build process, and user may see errors such as:
Error (active) XARDF7019 System.UnauthorizedAccessException: Access to the path 'GoogleGson.dll' is denied.
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at Xamarin.Android.Tasks.RemoveDirFixed.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/RemoveDirFixed.cs:line 54 MauiApp2 (net9.0-android) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.99.0-preview.6.340\tools\Xamarin.Android.Common.targets 2503
dotnet/android-tools@60fae192 introduced the concept of a "Retry" in
the cases of `UnauthorizedAccessException`s or `IOException`s when
the code is `ACCESS_DENIED` or `ERROR_SHARING_VIOLATION`.
Builds upon that work to use the API's added to add retry semantics
to the `<RemoveDirFixed/>` task.
This also simplifies the Task somewhat as it had quite complex
exception handling.
[0]: https://github.com/dotnet/project-system
[1]: https://github.com/microsoft/VSProjectSystem
Fixes https://github.com/dotnet/android/issues/9133 Context: https://learn.microsoft.com/visualstudio/msbuild/copy-task?view=vs-2022
The Design Time Build (DTB) seems to lock files and directories during its build process. This is not by design it is just that sometimes a build will try to do something with a file that the DTB already has open.
Users will sometimes see this error.
PR https://github.com/dotnet/android-tools/pull/245 introduced the concept on a "Retry" in the cases of
UnauthorizedAccessException
orIOException
when the code isACCESS_DENIED
orERROR_SHARING_VIOLATION
. This commit builds on that work to use the API's added to add retry semantics to theRemoveDirFixed
task.This also simplifys the Task somewhat as it had quite complete exception handling.