Building UE 4.27 with VS 2026

Rod Villani
Thu, 19 Feb 2026 05:09:30 +0000
C++

If, like me, you refuse to install an older VS when you have to work on older projects, you might get a bunch of errors from the AutomationTool if you happen to have an MSBuild.exe under this path:

C:\Windows\Microsoft.NET\Framework64\v4.0.xxxx

If you don’t, I don’t even know what sort of errors it will throw. But the issue when it finds that old MSBuild is that it fails to recognize the newer C# features in the automation scripts.

UE 4.27 is prepared to recognize installations of VS up to 2022. But the code has a fallback, where it caches the path of newer installations as if it was a 2022 one. The problem is that the function TryGetMsBuildPath is only looking for 2019 and older. The fix is to have it recognize 2022, and it will work with whatever path was found, even for newer installations.

Modify the function TryGetMsBuildPath inside UEBuildWindows.cs by duplicating the existing code for 2019 and replacing occurrences of 2019 with 2022:

public static bool TryGetMsBuildPath(out FileReference OutLocation)
{
	// BEGIN CUSTOM - Get the Visual Studio 2022 install directory
	List<DirectoryReference> InstallDirs2022 = WindowsPlatform.FindVisualStudioInstallations(WindowsCompiler.VisualStudio2022).ConvertAll(x => x.BaseDir);
	foreach (DirectoryReference InstallDir in InstallDirs2022)
	{
		FileReference MsBuildLocation = FileReference.Combine(InstallDir, "MSBuild", "Current", "Bin", "MSBuild.exe");
		if (FileReference.Exists(MsBuildLocation))
		{
			OutLocation = MsBuildLocation;
			return true;
		}
	}
	// END CUSTOM

	// Get the Visual Studio 2019 install directory
	...

Now, your project files should generate fine.

When things start building as expected, there will be an error from some code in RenderGraphPrivate.cpp. I don’t have the log anymore, but it’s something about arithmetic overflow. It’s probably due to new checks on newer compilers, and it’s caused by the use of the INFINITY macro in GetClobberColor. To fix it, while still using infinity as a value, I used std::numeric_limits<float>::infinity():

FLinearColor GetClobberColor()
{
	switch (GRDGClobberResources)
	{
	case 1:
		return FLinearColor(1000, 1000, 1000, 1000);
	case 2:
		return FLinearColor(NAN, NAN, NAN, NAN);
	case 3:
	// BEGIN CUSTOM - Fix compilation error about arithmetic overflow with VS 2026
	{
		constexpr float Infinity = std::numeric_limits<float>::infinity();
		return FLinearColor(Infinity, Infinity, Infinity, Infinity);
	}
	// END CUSTOM
	case 4:
		return FLinearColor(0, 0, 0, 0);
	default:
		return FLinearColor::Black;
	}
}

Don’t forget to add #include <limits> at the top of that file, after the existing include, to use that std value.

#include "RenderGraphPrivate.h"

// BEGIN CUSTOM - Added to use infinity in GetClobberColor
#include <limits>
// END CUSTOM

Things seem to be working for now. I was just trying to compile the RiderLink plugin on Rider. Now I’ll try building a project and will report other issues I find.

3 posts - 1 participant