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

Should we push this on Unreal Engine build tool bug reports ? ( with help from gpt.. so it may be hallucinating… check me if you see anything wrong .. )

:lady_beetle: Bug: UnrealBuildTool Crashes During BuildPlugin When SupportedTargetTypesAttribute Is Missing

Summary

Starting in Unreal Engine 5.3 and continuing through 5.4 and 5.5, UnrealBuildTool crashes when using the BuildPlugin command on plugins that do not define a [SupportedTargetTypes] attribute on their ModuleRules class.

This results in an ArgumentNullException and is especially disruptive to plugin developers and IDE tooling like JetBrains Rider, which uses BuildPlugin as part of its integration workflow.


Reproduction Steps

  1. Create or install a plugin whose *.Build.cs file does not declare [SupportedTargetTypes].

  2. Run the following command:

    Engine\Build\BatchFiles\RunUAT.bat BuildPlugin -Unversioned -Plugin="Path\To\Plugin.uplugin" -Package="SomeOutputFolder"
    
  3. Observe the crash in UBT:

    System.ArgumentNullException: Value cannot be null. (Parameter 'element')
    at System.Attribute.GetCustomAttributes(MemberInfo element, ...)
    at UnrealBuildTool.ModuleRules.IsValidForTarget(...)
    

Root Cause

UBT tries to reflect over the ModuleRules class using:

var supportedTargetTypes = moduleType
    .GetCustomAttributes<SupportedTargetTypesAttribute>()
    .SelectMany(x => x.TargetTypes)
    .Distinct();

If the attribute is missing, this throws a NullReferenceException or ArgumentNullException.


Proposed Fix (Works in Practice)

Patch UnrealBuildTool\Configuration\ModuleRules.cs by wrapping the call in a safe try/catch:

IEnumerable<TargetType> supportedTargetTypes = new TargetType[] { };
try
{
    supportedTargetTypes = moduleType
        .GetCustomAttributes<SupportedTargetTypesAttribute>()
        .SelectMany(x => x.TargetTypes)
        .Distinct();
}
catch
{
    string moduleName = moduleType?.Name ?? "<null>";
    invalidReason = $"TargetType '{targetRules.Type}' : Failed to get SupportedTargetTypesAttribute from '{moduleName}'";
    return false;
}

This logs the issue but avoids the crash and allows the toolchain to continue.


Why This Matters

  • This breaks plugin compilation for otherwise valid code.
  • It affects Rider, automated build pipelines, and tools that depend on BuildPlugin.
  • Plugin authors may not know they need to explicitly declare [SupportedTargetTypes] and shouldn’t be penalized for its omission.
  • The crash is non-informative and doesn’t indicate the actual problem.

Workaround

Manually patch and recompile UBT:

  1. Open:

    Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.sln
    
  2. Edit:

    Configuration\ModuleRules.cs
    
  3. Patch the IsValidForTarget method as above.

  4. Build the solution and replace the generated DLL:

    Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll
    

Request

Please update UBT in the next engine release (5.5.2 or 5.6+) to:

  • Handle missing [SupportedTargetTypes] gracefully
  • Log a clear warning or fallback message
  • Avoid ArgumentNullException or fatal reflection errors

This will improve developer UX, unblock toolchains, and prevent confusion.


References

3 Likes