[NativeAot] Failed to write Java.Interop.dll when deploying from VS2026
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 252
Description
### Versions
net10.0
android 36.1
VS2026 18.0.2
### Description
When deploying to android emulator from VS2026 a dotnet maui app built with `PublishAot=true`, I get an exception, not always but most of the time.
### Steps to Reproduce
1. dotnet new maui -n TestNativeAot
2. add `true` to csproj
3. build and deploy to android emulator (release configuration)
### Did you find any workaround?
I've tried to delete obj/bin folders, killed adb and msbuild, reboot my machine.
I've also added `android-x64` to the csproj to make sure vs builds only for 1 rid... but I'm not sure it works.
No matter what I do, the exception is raised most of the time.
### Relevant log output
[binlog](https://github.com/user-attachments/files/23752424/CentralNode_devenv_PID.36784_x64_BuildManager_Unnamed_10.zip)
```shell
IL1011: Failed to write 'obj\Release\net10.0-android36.1\android-x64\linked\Java.Interop.dll'.
Fatal error in IL Linker
Unhandled exception. Mono.Linker.LinkerFatalErrorException: ILLink: error IL1011: Failed to write 'obj\Release\net10.0-android36.1\android-x64\linked\Java.Interop.dll'.
---> System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. : 'obj\Release\net10.0-android36.1\android-x64\linked\Java.Interop.dll'.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at Mono.Cecil.AssemblyDefinition.Write(String fileName, WriterParameters parameters)
at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writerParameters)
--- End of inner exception stack trace ---
at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writerParameters)
at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory)
at Mono.Linker.Steps.OutputStep.OutputAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.OutputStep.ProcessAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.