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
Error:
... 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.
Update:
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 …