Hi, I’m trying to figure out an issue that I have while trying to build on a docker-windows container.
This issue happens always it doesn’t matter if you are running docker as a single process or with hyper-v activated.
##### Custom Environment Variables
DOTNET_MULTILEVEL_LOOKUP=0
##### ExitCode
1
##### Output
error CS2012: Cannot open 'C:\builds\project\Library\Bee\artifacts\StandaloneWindows64_CodeGen\Mirror.dll' for writing -- 'The process cannot access the file 'C:\builds\project\Library\Bee\artifacts\StandaloneWindows64_CodeGen\Mirror.dll' because it is being used by another process.'
[ 776/1045 0s] Csc Library/Bee/artifacts/StandaloneWindows64_CodeGen/Unity.Burst.CodeGen.dll (+2 others)
##### CommandLine
"C:\Program Files\Unity\Hub\Editor\2021.3.28f1\Editor\Data\NetCoreRuntime\dotnet.exe" exec "C:/Program Files/Unity/Hub/Editor/2021.3.28f1/Editor/Data/DotNetSdkRoslyn/csc.dll" /nostdlib /noconfig /shared " @ /Bee/artifacts/StandaloneWindows64_CodeGen/Unity.Burst.CodeGen.rsp"
##### Contents of Library\Bee\artifacts\StandaloneWindows64_CodeGen\Unity.Burst.CodeGen.rsp
-target:library```
This is one of the errors that I get while compiling the project.
```/additionalfile:"Library/Bee/artifacts/StandaloneWindows64_CodeGen/Unity.Burst.CodeGen.AdditionalFile.txt"
##### Custom Environment Variables
DOTNET_MULTILEVEL_LOOKUP=0
##### ExitCode
1
##### Output
error CS2012: Cannot open 'C:\builds\project\Library\Bee\artifacts\StandaloneWindows64_CodeGen\Unity.Burst.CodeGen.dll' for writing -- 'The process cannot access the file 'C:\builds\project\Library\Bee\artifacts\StandaloneWindows64_CodeGen\Unity.Burst.CodeGen.dll' because it is being used by another process.'
*** Tundra build failed (26.79 seconds), 591 items updated, 1045 evaluated```
What could be producing this errors?
Thank you in advance for any leads or ideas :)
First, make a blank project with a single blank scene and prove that it builds successfully.
If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.
Until you can build a blank project to the target platform, don’t fiddle with anything else.
Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.
Most often things that prevent building are third-party libraries such as Firebase.
Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.
It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.
Android build not building:
Recently (circa July 2022) there have been reports of Unity’s installer failing to install the Android Tools.
Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33…):
That message is essentially a prompt to reboot your computer.
After a reboot there shouldn’t be any processes still having a lock on that file. However, that particular error may come up again AFTER the first build attempt fails, because it seems likely that a failed build is what’s causing those frozen processes.
If that is the case be sure to focus ONLY on the errors you get when making the first build (and reboot every time you get “used by another process”) because all following build failurs are likely due to the hanging processes, not the actual build issue.
Just a hunch, never used Docker but be sure none of that part of your work environment tries to access or keeps using these DLL files. It shouldn’t because the Library folder contains only transient data but just in case.
Lastly, if you have a separate antivirus program installed, uninstall it (at least exclude the project folder from “live” scans). Those antivirus malware (that’s what they are these days) are more likely to cause systemic issues, come with their own security flaws and generally waste your time with false alerts. Windows Defender is more than capable.
I try to do a bit more investigation regarding this issue. I’m still stuck but defenetly it is related to Burst compiler and building the addressables of our game. When the addressables are build those file are generated and those files will also be generated when doing a build, for some reason after building the addressables those specific two files will neve be released and when the build process comes in it tries to overwrite them and boom they are blocke and the whole process fall appart.
I divided my scripts into two in order to call unity from command line to build first the addressables, I gave a substantial wait time after the process exited sucessfuly and then calling the build process also from command line but the result was the same. It tries to get which process was using those dlls but then the execution of the script hangs.
Ok I found the solution to my issue regarding Docker.
The issue was produced probably by an incopatibility in the Kernel of host Windows machine installation and the version of the Kernel on the Windows docker image.
The host machine has a kernel 22H2 and my images where 1809 and 21H2. I found a ticket in GitHub that claimed that if you wanted docker-windows do execute properly the docker images on a 22H2 host in a single process without Hyper-V one should create the images using the kernel 2004. I did it so and all my problems went away.
I hope someone finds this infor helpful at some point