GitHub 5.0 from scratch fails on no UnrealBuildTool

I’ve previously successfully built various versions of UE4 on this machine. It has Visual Studio 2019 plus all the various dependencies from those versions already installed.

I checked out github, the 5.0 branch, into D:\UE5. I ran Setup.bat with no errors. I ran GenerateProjectFiles.bat, which just runs Engine\Build\BatchFiles\GenerateProjectFiles.bat

It runs GetDotNetPath.bat which works, and generates a list of .cs files into Intermediate\Build\UnrealBuildToolFiles.txt

The two dotnet msbuild commands that it runs while inside Engine\Source work fine:
dotnet msbuild /target:clean /property:Configuration=Development /nologo Programs\UnrealBuildTool\UnrealBuildTool.csproj /verbosity:quiet
dotnet msbuild /restore /target:build /property:Configuration=Development /nologo Programs\UnrealBuildTool\UnrealBuildTool.csproj /verbosity:quiet

(It may not even run the clean, but I ran it manually and it works.)

It then gets to try to run UnrealBuildTool.dll which fails – the tool isn’t actually built:
dotnet ..\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll -ProjectFiles

... You intended to execute a .NET Core program, but dotnet-..\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll does not exist ...

Apparently, the msbuild that’s supposed to build it (the last msbuild above) fails, but without an error code or message? What’s up with this? What step am I missing?
Running it without quiet, it does show setting up some binaries, but in a different directory:

  EpicGames.Core -> D:\UE5\Engine\Source\Programs\Shared\EpicGames.Core\bin\x64\Development\netcoreapp3.1\EpicGames.Core.dll
  EpicGames.Build -> D:\UE5\Engine\Source\Programs\Shared\EpicGames.Build\bin\x64\Development\netcoreapp3.1\EpicGames.Build.dll
  UnrealBuildTool -> D:\UE5\Engine\Source\Programs\UnrealBuildTool\bin\x64\Development\UnrealBuildTool.dll

Note that that’s in a different output directory, though.
If I try to substitute that path in for the dotnet call instead, I get another error (caused by the tool itself):

ERROR: Unhandled exception: System.TypeInitializationException: The type initializer for 'UnrealBuildTool.UnrealBuildTool' threw an exception.
        ---> System.TypeInitializationException: The type initializer for 'UnrealBuildBase.Unreal' threw an exception.
        ---> System.Exception: This code requires that applications using it are launched from a path containing "Engine/Binaries/DotNET". This application was launched from D:\UE5\Engine\Source\Programs\UnrealBuildTool\bin\x64\Development
          at UnrealBuildBase.Unreal.FindRootDirectory() in D:\UE5\Engine\Source\Programs\Shared\EpicGames.Build\Unreal.cs:line 57

So, how is the right version of UnrealBuildTool supposed to end up in Engine/Binaries/DotNET ? I’ve tried reading the github docs and the getting started docs but they are silent on this, and a Google doesn’t say anything obvious.

There’s a work-around. If I properly build the cs project (which I can do from the command line, or it happens before the failure in the generate-projects batch file,) and then copy all .dll and .json files from D:\UE5\Engine\Source\Programs\UnrealBuildTool\bin\x64\Development into a (new) Source\Binaries\DotNet\UnrealBuildTool directory, then I can run this.

If I do not copy the .json files from the build output directory, then I get this error:

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\UE5\Engine\Binaries\DotNET\UnrealBuildTool\'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the D:\UE5\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.runtimeconfig.json file specifying the appropriate framework.

Hopefully this post at least helps someone else searching for the same error messages. And, even more hopefully, someone who knows how this is supposed to work, can actually make it work.
I could provide a patch that adds the appropriate “copy” commands, perhaps, but I’m not sure that’s what you really want to do each time you generate project files …


I’m still getting this in April. What’s the most recent released branch?

1 Like

You can always fine the latest release here (make sure you’re logged in to Github to see the link):

You likely are missing the proper DotNET Runtime SDK, MS Build Tools (v142 for 5.0 I believe), or potentially a bad PATH setup or permissions issue. You can always find the build environment setup in the Release Notes:

Hi @jwatte

Hi had the same issue as you, but for me it was creating the files on the \bin\Win64 folder:

15:57:32    Determining projects to restore...
15:57:32    All projects are up-to-date for restore.
15:57:32    EpicGames.Core -> D:\perforce\FrontierGame_Test1\code\Engine\Source\Programs\Shared\EpicGames.Core\bin\Win64\Development\netcoreapp3.1\EpicGames.Core.dll
15:57:32    EpicGames.Build -> D:\perforce\FrontierGame_Test1\code\Engine\Source\Programs\Shared\EpicGames.Build\bin\Win64\Development\netcoreapp3.1\EpicGames.Build.dll
15:57:32    UnrealBuildTool -> D:\perforce\FrontierGame_Test1\code\Engine\Source\Programs\UnrealBuildTool\bin\Win64\Development\UnrealBuildTool.dll

After a while of investigation, the issue was related with the environment variable “PLATFORM”

The dotnet msbuild uses this variable to set the property “Platform”.

As in the UnrealBuildTool.cs there are only rules for the Platform “AnyCPU”, it does not match and not uses the Binaries\DotNET folder:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Development|AnyCPU' ">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Check the env variables and set empty or delete “PLATFORM”


Confirmed on latest builds. Batch file does not properly handle PLATFORM environment variable set via MSVC Command shortcuts. Building with MSVC 2022 install, MSVC 2019 build tools add from “Individual Components” using a Terminal Profile with this command line:

%comspec% /k "D:\PATH_TO_MSVC_ROOT\2022\Pro\VC\Auxiliary\Build\vcvars64.bat amd64 -vcvars_ver= && set PLATFORM=

Cesar++ for the diligent assessment.

1 Like

Thanks a lot for your generous infos.

Same problem occurs when I try to build the UE5.0&UE5.1 branch.(UE5.2 is OK)
I’ve tried the same approach for a workaround for this problem.
(pretty hard for newbie to figure out how to do it…)

[Workaround](confirmed in UE5.0 branch)

  1. clone the repo of unreal engine
  2. before execute Setup.bat, replace the UnrealBuildTool.csproj file with the [uploaded 5.0 one][1] or [uploaded 5.1 one][2] (edited based on UE5.2’s same file,seems like that they’ve correct the problem in UE5.2)
  3. run Setup.bat and etc

UnrealBuildTool.csproj (7.9 KB_UE5.1)
UnrealBuildTool.csproj (6.8 KB_UE5.0)