Quick answer: Unreal Build Tool could not find a usable C++ toolchain. Visual Studio is missing the Game development with C++ / Desktop development with C++ workload, the MSVC toolset or a Windows SDK, or your engine version needs a different Visual Studio. Install those components, or pin a compiler in BuildConfiguration.xml.

This one confuses people because Visual Studio is very obviously installed. UBT is not looking for the IDE, though. It is looking for a specific compiler toolchain and Windows SDK, and the default Visual Studio install does not include them. It also appears when you package a Blueprint project that contains a code plugin.

The exact error

In the Output Log or the packaging log:

ERROR: Visual Studio 2022 must be installed in order to build this target.

Older engines say “Visual Studio 2019”, and some versions add the architecture (“Visual Studio 2022 x64 must be installed”). Related messages from the same root cause include “Unable to find valid C++ toolchain” and “Windows SDK must be installed in order to build this target”.

Fix 1: install the components UBT needs

Open the Visual Studio Installer, choose Modify on your Visual Studio 2022 install, and make sure these are ticked:

Visual Studio Code is an editor, not a compiler; it does not satisfy UBT on its own. If you use Rider or VS Code, install the Visual Studio 2022 Build Tools with the same C++ components.

Fix 2: match Visual Studio to your engine version

Each Unreal version supports a specific range of compilers. UE 5.0 to 5.3 build with Visual Studio 2019 or 2022; UE 5.4 and later build only with Visual Studio 2022. Check the “Setting Up Visual Studio” page for your exact engine version: it lists the recommended toolset version, and very new toolsets are sometimes not supported until a later engine hotfix.

If you have several toolsets installed and UBT picks the wrong one, pin it. Create or edit %APPDATA%\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
  <WindowsPlatform>
    <Compiler>VisualStudio2022</Compiler>
    <!-- optional: pin an installed MSVC toolset version -->
    <CompilerVersion>14.38.33130</CompilerVersion>
  </WindowsPlatform>
</Configuration>

Toolset versions installed on your machine are the folder names under C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC.

Fix 3: packaging a Blueprint-only project

A Blueprint-only project normally packages without a compiler. The moment it contains a plugin with C++ source in its own Plugins folder (a Fab or Marketplace code plugin, for example), packaging has to compile that plugin, and UBT needs Visual Studio. Either install Visual Studio with the components above, or install the plugin to the engine through the Epic launcher, which provides prebuilt binaries for that engine version.

Check UBT can see the toolchain

After installing, close the editor and IDE, then regenerate project files. In the generated output or the next build log, UBT prints which compiler and Windows SDK it selected. If it still fails, run UBT once from a terminal to see the full detection output:

"C:\Program Files\Epic Games\UE_5.4\Engine\Build\BatchFiles\Build.bat" ^
  MyGameEditor Win64 Development -Project="D:\Projects\MyGame\MyGame.uproject" -WaitMutex

Once it builds

Toolchain changes are also one of the quieter ways a build changes behavior: a new MSVC version can expose undefined behavior that never crashed before. If you ship to players, Bugnet's Unreal SDK files crashes and ensures with the build version attached, so a regression that starts with the build where you switched compilers stands out on its own.

Frequently asked questions

Why does Unreal say Visual Studio must be installed when it is?

Unreal Build Tool needs the C++ workloads, an MSVC toolset and a Windows SDK, not just the IDE. Add Game development with C++ and Desktop development with C++ in the Visual Studio Installer.

Which Visual Studio version does Unreal Engine 5 need?

UE 5.0 to 5.3 support Visual Studio 2019 and 2022. UE 5.4 and later require Visual Studio 2022. Check your engine version’s setup page for the recommended toolset.

Why does a Blueprint project need Visual Studio to package?

Because it contains a plugin with C++ source in the project’s Plugins folder, which must be compiled. Install Visual Studio or install the plugin to the engine with prebuilt binaries.

UBT wants a compiler and a Windows SDK. The IDE is optional; the C++ workload is not.