Skip to content

IOException in AssemblyModifierPipeline #11022

@molesmoke

Description

@molesmoke

Android framework version

net10.0-android

Affected platform version

.NET 10.0.201

Description

When trying to build an Android MAUI app in a Windows container, the build fails with an IOException from AssemblyModifierPipeline

Steps to Reproduce

I will try and come up with a minimal repro, but I note that the SourceFiles parameter to AssemblyModifierPipeline includes duplicate entries, and it appears to perform write operations on files in the .nuget/packages directory e.g.

D:\.nuget\packages\microsoft.maui.controls.core\10.0.50\lib\net10.0-android36.0\ar\Microsoft.Maui.Controls.resources.dll
D:\.nuget\packages\microsoft.maui.controls.core\10.0.50\lib\net10.0-android36.0\ar\Microsoft.Maui.Controls.resources.dll

File.SetLastWriteTimeUtc (destination.ItemSpec, DateTime.UtcNow);

Inspecting those files does show that the file access times are indeed being modified.

Did you find any workaround?

Building on the host works OK, but not in a container.

Relevant log output

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\36.1.30\tools\Xamarin.Android.Common.targets(1501,3): error XAAMP7024: The file is locked by: "MSBuild.exe (3028)".
System.IO.IOException: The process cannot access the file 'C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.core\10.0.50\lib\net10.0-android36.0\ar\Microsoft.Maui.Controls.resources.dll' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
   at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
   at Xamarin.Android.Tasks.SaveChangedAssemblyStep.ProcessAssembly(AssemblyDefinition assembly, StepContext context)
   at Xamarin.Android.Tasks.AssemblyPipeline.Run(AssemblyDefinition assembly, StepContext context)
   at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunTask()
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute() [C:\src\project\App.csproj]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions