GenerateProjectFiles.bat with VS 2019

Hello! i’m having a problem building UE from sources. i have VS2019 with c# and c++ installed. (also i couldn’t find tag for VS 2019)

so I did simple things:

and from the last CMD command i got a list of errors:

Platform\Mac\UEBuildMac.cs(71,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Mac\UEBuildMac.cs(95,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
System\BuildVersion.cs(264,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
System\BuildVersion.cs(318,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Configuration\TargetRules.cs(1516,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Configuration\TargetRules.cs(2317,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Android\UEBuildAndroid.cs(56,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Android\UEBuildAndroid.cs(70,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\IOS\UEBuildIOS.cs(87,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\IOS\UEBuildIOS.cs(125,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\HTML5\UEBuildHTML5.cs(56,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\HTML5\UEBuildHTML5.cs(65,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Linux\UEBuildLinux.cs(94,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Linux\UEBuildLinux.cs(118,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Lumin\UEBuildLumin.cs(50,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Lumin\UEBuildLumin.cs(59,25): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Windows\UEBuildWindows.cs(301,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Windows\UEBuildWindows.cs(440,27): warning CS1692: Invalid number [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Mac\UEBuildMac.cs(79,15): warning CS1591: Missing XML comment for publicly visible type or member 'UnrealBuildTool.ReadOnlyMacTargetRules.bEnableAddressSanitizer' [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Mac\UEBuildMac.cs(84,15): warning CS1591: Missing XML comment for publicly visible type or member 'UnrealBuildTool.ReadOnlyMacTargetRules.bEnableThreadSanitizer' [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Platform\Mac\UEBuildMac.cs(89,15): warning CS1591: Missing XML comment for publicly visible type or member 'UnrealBuildTool.ReadOnlyMacTargetRules.bEnableUndefinedBehaviorSanitizer' [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\BuildMode.cs(157,17): error CS0136: A local variable named 'RemoteMac' cannot be declared in this scope because it would give a different meaning to 'RemoteMac', which is already used in a 'parent or current' scope to denote something else [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\CleanMode.cs(88,29): error CS0136: A local variable named 'TargetDescriptor' cannot be declared in this scope because it would give a different meaning to 'TargetDescriptor', which is already used in a 'parent or current' scope to denote something else [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\CleanMode.cs(216,22): error CS0136: A local variable named 'TargetDescriptor' cannot be declared in this scope because it would give a different meaning to 'TargetDescriptor', which is already used in a 'parent or current' scope to denote something else [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\CleanMode.cs(219,16): error CS0136: A local variable named 'RemoteMac' cannot be declared in this scope because it would give a different meaning to 'RemoteMac', which is already used in a 'parent or current' scope to denote something else [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\JsonExportMode.cs(26,29): error CS0136: A local variable named 'TargetDescriptor' cannot be declared in this scope because it would give a different meaning to 'TargetDescriptor', which is already used in a 'parent or current' scope to denote something else [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\GenerateProjectFilesMode.cs(24,44): error CS0103: The name 'nameof' does not exist in the current context [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\GenerateProjectFilesMode.cs(25,44): error CS0103: The name 'nameof' does not exist in the current context [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\GenerateProjectFilesMode.cs(26,33): error CS0103: The name 'nameof' does not exist in the current context [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]
Modes\GenerateProjectFilesMode.cs(27,33): error CS0103: The name 'nameof' does not exist in the current context [\UnrealEngine\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj]

System\ActionGraph.cs(201,17): error CS0135: 'Action' conflicts with the declaration 'UnrealBuildTool.Action'

GenerateProjectFiles ERROR: UnrealBuildTool failed to compile.

Same issue here! I also installed the C++ and C# toolchain for VS2019 Enterprise. I checked out the release branch.

This is a bug in latest release of UE 4.22 .
I also had the same issue.

They have already fixed it, but will be release as hot fix.
Here is the commit for the fix.
Commit Link for Fix.

Just cherry pick it will work.
Or else copy the contents form remote to that file in your local.

So it generates successfully. But I m getting compilation error in VS2019, so it fails.
But atleast I was able to generate project files.

Based on the invalid number warning, and the nameof error, it appears that the C# code is being compiled with C# 5 or older, and requires C# 6. The code hasn’t changed, so something else has shifted and we’re now getting the wrong C# compiler or compiler flags when building the UE 4.22.0 source.

It’s probably related to Engine/Source/Programs/UnrealBuildTool/UnrealBuildTool.csproj lines 2 and 15, which changed the ToolVersion and TargetFrameworkVersion.

Particularly interesting is that the same change was made before 4.21, and then reverted before release with the note

due to builders not having .NET 4.6.2

Anyway, check your Visual Studio Installer, and ensure you have the .NET Framework 4.6.2 SDK and targeting pack installed, and try the build again. Support for 4.6.2 is Optional in VS2019, not Recommended, so it won’t be installed if you just installed the .NET desktop development workload. It’s also optional in VS0217, so I expect more people will be hitting this issue.

This turned out to not be the issue, when I tested the fix. It turns out, my docker system is using VS2019 underneath me.

so i did

  • git cherry-pick fc7c25f48e1e1143f7c4a1d410e05eca5191ff24
  • GenerateProjectFiles.bat -2019

and now it tries to find VS2017:
GenerateProjectFiles ERROR: We couldn’t find a valid installation of Visual Studio. This program requires Visual Studio 2017.

I had the same issue, I cherry picked the commit and it generated project files.

I only have vs 2019 installation.

In my vs 2019 installation, I made sure that I install all different version of .NET starting from 3.0 to latest available in VS 2019 installer.

See this guys.

The issue reported has the same log.

OK, i fixed it by installed 4.5 .NET target pack.

but i already have it

273306-untitled.png

okay it looks like i found the problem, i had it installed as prerelease so i had to add -prerelease flag to the same file on line 13 and then it generated project files

I fixed it by simply checking out the 4.22 branch instead of the release one so I don’t have to cherry pick it. Now it works fine!

Does mentioning UE-72173 in a comment on the question cause it to link to the Issue page?

I guess not, it’d have to be added to the question itself.

I had issues with 4.23.0-release branch.

I was using Visual Studio 2019

I had to check off 4.6.2 SDK
And also the General .NET package which allowed for 4.6 in general.

Hope this helps!