Error MSB3021 Access to the path 'EpicGames.Core.dll' is denied.

Happen at Building and cleaning UE5 Source. It’s should be a Windows 10 security policy issue.

I already tried:

  1. Run Visual Studio 2022 Community as Admin and rebuild the solution. Not working.
  2. Create a new local Admin account and rebuild. Not working.
  3. Rebuild the solution with normal Microsoft account. Not working.
  4. 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!!!
  5. Change the specific dll files(such as EpicGames.Core.dll) security policy to, not declines the changes but still not working.
  6. Checked Windows File System Privacy Setting, it’s always ON.
  7. Switch Windows 11 SDK 10.0.22000 to Windows 10 SDK 10.0.20348. Not working.
  8. 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.

UnrealBuildToll build failure blocking everything compile related. Quiet annoying.

Same issue here :pensive: .

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:

I switched to Visual Studio 2019 and it does work.

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]

I was able to fix it on my side.

  • I Switched to Visual Studio 2022 (and removed VS 2019 to be sure.)
  • In Visual studio 2022 Installation → Individual components I add “.NET Core 3.1 Runtime”
  • And I run GenerateProjectFiles with the command “2022” for Visual Studio 2022 GenerateProjectFiles.bat -2022
  • I run UE5.sln with Visual Studio 2022
  • In VS Right clic on UE5 → Clear
  • And clic on UE5 → Rebuild

And it worked.

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.

Would you like to provide the exact steps? It seems a solution for this issue and I’d like to have a try.

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.

  1. Try to build all project one by one manually instead of building the whole solution if your repository is new and clear.
  2. 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.
  3. 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.

1 Like

The issue already fixed on Nov 22, 2022. Details at https://github.com/EpicGames/UnrealEngine/commit/5a761d5e44c535cdd6069bb99c786f02c7abe33b.
I don’t know why I didn’t pull the chance from Github at early. It seems that pushed at Unreal Engine 5.1.1 release.