Happen at Building and cleaning UE5 Source. It’s should be a Windows 10 security policy issue.
I already tried:
Run Visual Studio 2022 Community as Admin and rebuild the solution. Not working.
Create a new local Admin account and rebuild. Not working.
Rebuild the solution with normal Microsoft account. Not working.
Change the folder security policy for users to Full Control. Still not working. During policy changing, many files declines the security policy changes. I have to cancel it or I have to click “Continue” one by one the dialog pops up. IT ALSO LEAD MY FOLDER SECURITY POLICY INCONSISTENT and CORRPUTED!!!
Change the specific dll files(such as EpicGames.Core.dll) security policy to, not declines the changes but still not working.
Checked Windows File System Privacy Setting, it’s always ON.
Switch Windows 11 SDK 10.0.22000 to Windows 10 SDK 10.0.20348. Not working.
Turn on Windows 10 Developer Mod. Not working.
Environment Setting:
Visual Studio 2022 Community
Windows SDK 10.0.20348
.NET SDK
.NET 6.0 Runtime
.NET 7.0 Runtime
Here’s the error log.
> Setting up Unreal Engine project files...
> Using bundled DotNet SDK version: 6.0.302
>
> UnrealEngine\Engine\Binaries\ThirdParty\DotNet\6.0.302\windows\sdk\6.0.302\Microsoft.Common.CurrentVersion.targets(4809,5): error MSB3021: Unable to copy file "UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\bin\Development\netcoreapp3.1\EpicGames.Core.dll" to "..\..\..\Binaries\DotNET\UnrealBuildTool\EpicGames.Core.dll".
> Access to the path 'UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool\EpicGames.Core.dll' is denied.
>
> [UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
> UnrealEngine\Engine\Binaries\ThirdParty\DotNet\6.0.302\windows\sdk\6.0.302\Microsoft.Common.CurrentVersion.targets(4809,5): error MSB3021: Unable to copy file "UnrealEngine\Engine\Source\Programs\Shared\EpicGames.UHT\bin\Development\net6.0\EpicGames.UHT.dll" to "..\..\..\Binaries\DotNET\UnrealBuildTool\EpicGames.UHT.dll". Access to the path 'UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool\EpicGames.UHT.dll' is denied.
>
> [UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
> UnrealEngine\Engine\Binaries\ThirdParty\DotNet\6.0.302\windows\sdk\6.0.302\Microsoft.Common.CurrentVersion.targets(4809,5): error MSB3021: Unable to copy file "UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Build\bin\Development\net6.0\EpicGames.Build.dll" to "..\..\..\Binaries\DotNET\UnrealBuildTool\EpicGames.Build.dll". Access to the path 'UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool\EpicGames.Build.dll' is denied. [UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
GenerateProjectFiles ERROR: UnrealBuildTool failed to compile.
I found this happen when you try to build the whole solution.
Make the folder Engine\Binaries\DotNET and all dlls in it not hidden seems solve the problem:
Same with build from source when I run GenerateProjectFiles.bat
M:\MMVS_EngineFiles\UnrealEngine_MMVSBuild\Engine\Binaries\ThirdParty\DotNet\Windows\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(4364,5): error MSB3021: Impossible de copier le fichier "M:\MMVS_EngineFiles\UnrealEngine_MMVSBuild\Engine\Source\Programs\Shared\EpicGames.Core\bin\Development\netcoreapp3.1\EpicGames.Core.dll" vers "bin\Development\netcoreapp3.1\EpicGames.Core.dll". Access to the path 'M:\MMVS_EngineFiles\UnrealEngine_MMVSBuild\Engine\Source\Programs\Shared\EpicGames.Build\bin\Development\netcoreapp3.1\EpicGames.Core.dll' is denied. [M:\MMVS_EngineFiles\UnrealEngine_MMVSBuild\Engine\Source\Programs\Shared\EpicGames.Build\EpicGames.Build.csproj]
This triggers when you do full ‘Build Solution’ as a first step after project creation. Another workaround is to do only AutomationTool project build as a first step which seems to create all the stuff in the DotNET folder. After that everything seems to work fine here.
Yes. It only happen when build the whole solution. May get this error if your solution still remain in-compiled project more than one. You can build them manually one by one but it’s sucks if you gonna rebuild the whole project.
Share some temporary solutions for building in my case. Some may be suck but at least you can process with your work if not gonna touch the engine source.
Try to build all project one by one manually instead of building the whole solution if your repository is new and clear.
If you insist to build the whole solution. Build all C# Project or some important C# project(such as UnrealBuildTool and EpicGames.Build) first, then you can try to build the whole solution.
If got error MSB3021 during building solution. Try to delete the .dll files motioned in Build Output panel. For example, we have Unable to copy file "UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Build\bin\Development\net6.0\EpicGames.Build.dll" to "..\..\..\Binaries\DotNET\UnrealBuildTool\EpicGames.Build.dll".
Remove UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool\EpicGames.Build.dll and try again.
Try not to clean solution if your build is fine.
I think it’s not a system security policy.
In my case, those abnormal .dll files generation may be caused by the multi-threading. Just like I unable to compile C++ project with the source version of UE 5.1. I guess threads are seizing the same resource and ruin the .dll. Will need more investigation.