Packaging Plugin Calls Wrong Version of Visual Studio

I’ve got a working blueprint function library plugin written in C++. I’ve got Visual Studio 2019 installed, although the development environment is in C:\Applications rather than C:\Programs (x86). When I try to package the plugin, I see this in the Output Log:

UATHelper: Package Plugin Task (Windows): Building plugin for target platforms: Android, IOS, Linux, LinuxAArch64, Win64, Win32
UATHelper: Package Plugin Task (Windows): Running: C:\Unreal4.26\UE_4.26\Engine\Binaries\DotNET\UnrealBuildTool.exe UE4Game Win64 Development -Project=C:\UnrealProjects\FileIOPlugin\BPFileIOPlugin\HostProject\HostProject.uproject -plugin=C:\UnrealProjects\FileIOPlugin\BPFileIOPlugin\HostProject\Plugins\BPFileIOPlugin\BPFileIOPlugin.uplugin -iwyu -noubtmakefi
les -manifest=C:\UnrealProjects\FileIOPlugin\BPFileIOPlugin\HostProject\Saved\Manifest-UE4Game-Win64-Development.xml -nohotreload -2017 -log=“C:\Users\couvilliw\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Unreal4.26+UE_4.26\UBT-UE4Game-Win64-Development.txt”
UATHelper: Package Plugin Task (Windows): ERROR: Visual Studio 2017 must be installed in order to build this target.

Summarizing what’s weird about that:

  • It’s attempting to package for a bunch of platforms, although in the .uplugin and .uproject files, I’ve whitelisted only Win64
  • It’s attempting to call Visual Studio 2017. In my AppData\Roaming\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml file, I’ve specified MSVS2019 as the Version in the VCProjectFileGenerator section

How do I make sure UnrealBuildTool uses the right version of Visual Studio?

I never really figured out the problem, but came up with this work-around:

  • Attempt to package the plugin from the editor
  • When the packaging fails, click “Show Output Log” in the popup
  • Find the last call to UnrealBuildTool.exe, which should be just above error message about Visual Studio not being installed
  • Copy the UnrealBuildTool.exe command into a .bat file
  • Change the -2017 command line argument to UnrealBuildTool.exe to -2019
  • Run the batch file (don’t ask me why this didn’t work from the command line, but it didn’t for me; I needed to make it a batch file)
  • Inside your package destination directory, there will be a directory PluginName/HostProject/Plugins/PluginName. The Content and Resources folders and the .uplugin file are your packaged plugin.

I don’t think it’s really different than just compiling your project with the new plugin, and copying the Content, Resources and .uplugin file.

there is no -2017 in the command line, no idea where this is configured

changing the toolchain does not work either

image