[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!

3 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.