[UBT Bug] No longer able to compile plugins in standalone since 5.3

Hey all!

Since 5.3, UBT crashes when compiling plugins in standalone mode (i.e. not part of a project).

Here’s the build command used to repro:

dotnet "<PathToEngine>\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" UnrealEditor Win64 Development -plugin=<PathToPlugin>\<PluginName>.uplugin

Here’s repro’s log:

Using user-specified engine root: z:\Unreal\UE_5.3
Using bundled DotNet SDK version: 6.0.302
Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" UnrealEditor Win64 Development -plugin=C:\PluginDevelopmentTemp\Plugins\ExpressiveText\ExpressiveText.uplugin
Log file: C:\Users\User\AppData\Local\UnrealBuildTool\Log.txt
Creating makefile for UnrealEditor (UnrealBuildTool assembly is newer)
Total execution time: 36.41 seconds
Unhandled exception: System.ArgumentNullException: Value cannot be null. (Parameter 'element')
   at System.Attribute.GetCustomAttributes(MemberInfo element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T](MemberInfo element)
   at UnrealBuildTool.ModuleRules.IsValidForTarget(Type ModuleType, ReadOnlyTargetRules TargetRules, String& InvalidReason) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Configuration\ModuleRules.cs:line 1623
   at UnrealBuildTool.UEBuildTarget.AddAllValidModulesToTarget(ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 3891
   at UnrealBuildTool.UEBuildTarget.PreBuildSetup(ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 3354
   at UnrealBuildTool.UEBuildTarget.Create(TargetDescriptor Descriptor, Boolean bSkipRulesCompile, Boolean bForceRulesCompile, Boolean bUsePrecompiled, UnrealIntermediateEnvironment IntermediateEnvironment, ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 1366
   at UnrealBuildTool.UEBuildTarget.Create(TargetDescriptor Descriptor, BuildConfiguration BuildConfiguration, ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 1208
   at UnrealBuildTool.BuildMode.CreateMakefileAsync(BuildConfiguration BuildConfiguration, TargetDescriptor TargetDescriptor, ISourceFileWorkingSet WorkingSet, ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 1114
   at UnrealBuildTool.BuildMode.BuildAsync(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options, FileReference WriteOutdatedActionsFile, ILogger Logger, Boolean bSkipPreBuildTargets) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 396
   at UnrealBuildTool.BuildMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 252
   at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in Z:\Unreal\UE_5.3\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 659

Going deep into UBT land, the problem seems to be related to changes to UEBuildTarget.cs:


UnrealBuildTool: Add SupportedTargetTypes attribute, allowing for Mod… · EpicGames/UnrealEngine@22d7100 (github.com)

GetModuleRulesType() is actually returning a null type because it can’t find it on the precompiled UE5Rules assembly - In my case it’s failing for “PoseCorrectives.Build.cs”, not sure if this is something specific to this module (it does go fine for many other engine plugin modules that come before).

I’ve also confirmed that other people are having the same issue. Someone using Plugin Builder has posted about the same issue (on the questions section):
Plugin Builder in Code Plugins - UE Marketplace (unrealengine.com)

It’s important to mention this issue does not reproduce when compiling the plugin as part of a project, or when using the same command on 5.2.

Tagging @Rinn.EG and @Naotsun for visibility

Cheers!

4 Likes

Added some extra logging and can confirm that the only modules rules missing are related to the PoseCorrectives plugin:

I am working with two different plugins, and one worked fine, but the other I get the same exception in the log, although I can’t see any “Failed to retrieve RulesType from module…” messages. This was attempting to do standalone test build of a plugin in preparation for release.

We added custom logging to UBT ourselves just to check which modules were failing (also skipping those modules). That’s why it doesn’t show “Failed to retrieve…” for you :slight_smile:

1 Like

I do wonder does the issue occur for everyone or only select few like me or original poster, and in those select few who experience issue, whats the cause

I ran into the same problem, what I did fixed it in this specific case:

  • Add the plugin directly into the project
  • Uninstall all your Plugins from the engine
1 Like

Very helpful thread- Thanks to everyone. I have been able to package my plugin by
a) pinpointing the problem causing installed plugin by adding additional logs in the .cs buildscript files
b) removing the plugin from the engine installation folder

1 Like

Hey, could you tell me what exactly you added to the .cs buildscript files? I am able to package the project with the plugin in the project directory, but I can’t package the plugin on it’s own and I also can’t package the project when the plugin is just in the engine plugin folder.
I was however able to compile the plugin in linux

(It’s a plugin I’ve written myself, but it’s pretty basic, so there is not a lot of things that can go wrong)

I can confirm that the same problem persists. I was unable to package standalone for 5.3, but managed to package via .sln inside the Plugins folder of the project.

sorry for the late reply, here are the changes necessary in the two files:
https://github.com/EpicGames/UnrealEngine/pull/11110/files

Hacking around I managed to both a) identify the problem plugins, and b) make the build tool immune to this crash.

  1. Open C:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.sln in Visual Studio
  2. Make Configuration/ModuleRules.cs writable
  3. Find the IsValidForTarget method
  4. Replace the first line of code with the code below.
  5. Compile with Build → Build Solution (make sure it completes ok and says it’s updated the C:\Program Files\Epic Games\UE_5.4\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll file.
  6. Attempt to build your project/plugin again
  7. Look in the “C:\Users_yourusername_\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.4” or similar folder for the .txt file with the long name.
  8. In it search for “Does not support” and see if the new code has triggered. The start of the line will tell you the plugin.
			IEnumerable<TargetType> supportedTargetTypes = new TargetType[] { };
			try
			{
				supportedTargetTypes = moduleType
					.GetCustomAttributes<SupportedTargetTypesAttribute>().SelectMany(x => x.TargetTypes).Distinct();
			}
			catch
			{
				string module_name = (moduleType != null) ? moduleType.Name : "<null>";
				invalidReason = $"TargetType '{targetRules.Type}' : Failed to get SupportedTargetTypesAttribute from '{module_name}'";
				return false;
			}
4 Likes

Thank you, @Sam_Swain, this is the way! This helped me track down the root cause of my issue – the OmniverseLiveLink plugin. After reading this thread, I suspected it might be the culprit since I recently installed it and started having this problem with building plugins a few days later.

@HellDunkelkeit I don’t believe the changes you linked are relevant to this issue.

Tried this change to core and it seemed to unstick my ability to compile a blank C++ project in Rider. Seems like it would be a sensible change to UE UBT codebase since it would help trace problems at compile time!! Also my first time changing any UE base / build tool code so very cool.

Not sure why, but changing this line and rebuilding UBT allowed me to actually build a plugin, I guess this was confusing the engine somehow.