Unable to build player

Whenever I try to build my project, it gives me the following error:

or "Library\Il2cppBuildCache\Windows\x64\artifacts\buildprogram\buildprogram.exe```
Anyone any idea how to fix this? Running as administrator does not fix it, and access permission should be set properly.

~~~
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEditor.FileUtil.UnityFileCopy (System.String from, System.String to, System.Boolean overwrite) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter, System.Boolean recursive) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryRecursiveFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryRecursive (System.String source, System.String target, System.Boolean overwrite, System.Boolean ignoreMeta) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.FileUtil.CopyDirectoryRecursive (System.String source, System.String target, System.Boolean overwrite) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo, System.String generatedCppOutputDirectory) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data, System.String outputDirectory, System.Boolean platformSupportsManagedDebugging) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditorInternal.IL2CPPBuilder.Run () (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
DesktopStandalonePostProcessor.RunIL2CPP (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditorInternal.IIl2CppPlatformProvider il2cppPlatformProvider, System.Collections.Generic.List`1[T] cppPlugins) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
DesktopStandalonePostProcessor.SetupStagingArea (UnityEditor.Modules.BuildPostProcessArgs args, System.Collections.Generic.HashSet`1[T] filesToNotOverwrite) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
DesktopStandalonePostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
DesktopStandalonePostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <b76552deb4624e46abeeb45b48b7f62d>:0)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
~~~

This looks like it might be error on the Unity side. I’ll check with some others and get back to you.

Hi, I have no idea what managed to fix it, but in order to be able to build, I changed over to Windows x32, which did allow me to build. I’ve tried with removing Burst compiler, with it imported, and maybe some more that I can’t remember.
I tried building x64 again today, and the build succeeded, giving me the same project, just in x64. For now, the issue is solved, but it bugs me not to know what caused it in the first place, or what fixed it.

I’m having the same error. Trying to build for WebGL, and IL2CPP keeps killing the build process.

IOException: Sharing violation on path Z:\Program Files\Unity Editors\2020.3.6f1\Editor\Data\il2cpp\build\BeeSettings\offline\artifacts\buildprogram\buildprogram.exe" or "Library\Il2cppBuildCache\WebGL\artifacts\buildprogram\buildprogram.exe
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEditor.FileUtil.UnityFileCopy (System.String from, System.String to, System.Boolean overwrite) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter, System.Boolean recursive) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryRecursiveFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryRecursive (System.String source, System.String target, System.Boolean overwrite, System.Boolean ignoreMeta) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.FileUtil.CopyDirectoryRecursive (System.String source, System.String target, System.Boolean overwrite) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditorInternal.IL2CPPBuilder.Run () (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.WebGL.WebGlBuildPostprocessor.CompileBuild (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:365)
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:913)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <e09fc44b2b464346872ad04477f51ab1>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

We were not able to determine what could cause this, and we were not able to reproduce it. Could there be some other application (maybe a virus scanner) locking these files?

We’re experiencing the same issue.

Our setup: Unity 2021.2.0f1, Android platform, IL2CPP, LZ4HZ, AAB (split application binary), other settings default. Using github actions Game CI (Builder | GameCI) to build (properly building on local machine).

It was building properly in unity 2021.1.X

Here’s a context of this error:

[2105/2162  0s] CopyFiles 
[2106/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.PhysicsModule_CodeGen.c
[2107/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/System.Data8.cpp
[2108/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/Unity.TextMeshPro3.cpp
[2109/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.VideoModule_CodeGen.c
[2110/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.IMGUIModule.cpp
[2112/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.AnimationModule_CodeGen.c
[2113/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/System.Xml.Linq.cpp
[2114/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/System.Xml5.cpp
[2115/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/Newtonsoft.Json1.cpp
[2116/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/Unity.Mathematics6.cpp
[2117/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/Assembly-CSharp_CodeGen.c
[2118/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.SpriteShapeModule_CodeGen.c
[2119/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutput/UnityEngine.SpriteShapeModule.cpp
[2120/2162  0s] CopyFiles /github/workspace/Library/Android/Prj/IL2CPP/Il2CppBackup/il2cppOutputException occurred inside BeeDriver: System.IO.IOException: Sharing violation on path /github/workspace/[Unknown]
  at System.IO.FileStream.WriteInternal (System.Byte[] src, System.Int32 offset, System.Int32 count) [0x00077] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at System.IO.FileStream.Write (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00090] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at System.IO.StreamWriter.Flush (System.Boolean flushStream, System.Boolean flushEncoder) [0x00080] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at System.IO.StreamWriter.WriteSpan (System.ReadOnlySpan`1[T] buffer, System.Boolean appendNewLine) [0x000a7] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at System.IO.StreamWriter.WriteLine (System.String value) [0x0000d] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at System.IO.TextWriter+SyncTextWriter.WriteLine (System.String value) [0x00000] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(string)
  at System.Console.WriteLine (System.String value) [0x00000] in <75405ec2242e43c49aa0483c7c7d5ed0>:0
  at Bee.BeeDriver.RunningProgram.get_HasExited () [0x00086] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.RunBackendPhase.Tick () [0x0001b] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.PhaseBase.Tick (System.Boolean blocked) [0x00009] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.BeeDriver.Tick (System.Boolean block) [0x00000] in <7d5b346e100b493a8d2db4abd4098568>:0
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /home/bokken/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
UnityEditor.Modules.BeeBuildPostprocessor:ReportBuildResults (Bee.BeeDriver.BeeDriverResult) (at /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs:458)
UnityEditor.Modules.BeeBuildPostprocessor:PostProcess (UnityEditor.Modules.BuildPostProcessArgs) (at /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs:540)
UnityEditor.Modules.DefaultBuildPostprocessor:PostProcess (UnityEditor.Modules.BuildPostProcessArgs,UnityEditor.BuildProperties&) (at /home/bokken/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:28)
UnityEditor.Android.AndroidBuildPostprocessor:PostProcess (UnityEditor.Modules.BuildPostProcessArgs,UnityEditor.BuildProperties&)
UnityEditor.PostprocessBuildPlayer:Postprocess (UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string,string,string,int,int,UnityEditor.BuildOptions,UnityEditor.RuntimeClassRegistry,UnityEditor.Build.Reporting.BuildReport) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:370)
UnityEditor.BuildPipeline:BuildPlayerInternal (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[]) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:448)
UnityEditor.BuildPipeline:BuildPlayer (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[]) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:347)
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:321)
UnityBuilderAction.Builder:BuildProject () (at Assets/Editor/Editor/UnityBuilderAction/Builder.cs:69)

(Filename: /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs Line: 458)

BuildFailedException: Incremental Player build failed!
  at UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) [0x00165] in /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs:556
  at UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) [0x00001] in /home/bokken/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:28
  at UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) [0x00009] in <7ab033eb8c694717b13ef23db4258a6e>:0
  at UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) [0x000e5] in /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:370
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:448)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:347)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline.bindings.cs:321)
UnityBuilderAction.Builder:BuildProject() (at Assets/Editor/Editor/UnityBuilderAction/Builder.cs:69)

Hey, @kbobnis , could you provide us a configuration file that you’ve used for building (feel free to do that in the private chat, provided no NDA restrictions are applied) ? We’re trying to reproduce the issue on our end in order to proceed with the investigation.

Same 2021.2.7

Same 2021.2.8f1…

+1

Have the same issue after upgrading from 2021.1.28 to 2021.2.8.

Here’s my stack trace:

[ 672/2330  0s] CopyFiles gradle_build/build/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/metadata/Il2CppTypeHash.h
[ 673/2330  0s] CopyFiles gradle_build/build/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/metadata/Il2CppTypeCompare.cpp
[ 674/2330  0s] CopyFiles gradle_build/build/unityLibrary/src/main/Il2CppOutputProjException occurred inside BeeDriver: System.IO.IOException: Sharing violation on path /Users/buildserver/builds/URC7sUL-/0/cargoempire/cargoempire-client/[Unknown]
  at System.IO.FileStream.WriteInternal (System.Byte[] src, System.Int32 offset, System.Int32 count) [0x00077] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at System.IO.FileStream.Write (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00090] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at System.IO.StreamWriter.Flush (System.Boolean flushStream, System.Boolean flushEncoder) [0x00080] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at System.IO.StreamWriter.WriteSpan (System.ReadOnlySpan`1[T] buffer, System.Boolean appendNewLine) [0x000a7] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at System.IO.StreamWriter.WriteLine (System.String value) [0x0000d] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at System.IO.TextWriter+SyncTextWriter.WriteLine (System.String value) [0x00000] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(string)
  at System.Console.WriteLine (System.String value) [0x00000] in <e7b4371ec0dc4ed2ab84299cc150e9c3>:0
  at Bee.BeeDriver.RunningProgram.get_HasExited () [0x00086] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.RunBackendPhase.Tick () [0x0001b] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.PhaseBase.Tick (System.Boolean blocked) [0x00009] in <7d5b346e100b493a8d2db4abd4098568>:0
  at Bee.BeeDriver.BeeDriver.Tick (System.Boolean block) [0x00000] in <7d5b346e100b493a8d2db4abd4098568>:0
BuildFailedException: Incremental Player build failed!
Unloading 1377 Unused Serialized files (Serialized files now loaded: 0)