Package error with K2Node

Hello! I am trying to package my project but I always get an error. I made a custom K2Node, which works perfectly on the editor, but when I package I get the following error:


Error: Couldn't find parent type for 'K2Node_GetSequenceBinding' named 'UK2Node' in current module or any other module parsed so far.

I suppose that I need to add some module dependency in the build file, but I don’t know which and where exactly. I have tried to add “BlueprintGraph” and “MovieSceneTool” but nothing is working. :frowning:

My current build files are:
[SPOILER]MyProject.Build.cs


using UnrealBuildTool;

public class MyProject : ModuleRules
{
    public MyProject(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string] { "AIModule" , "GameplayTags", "GameplayTasks", "UMG", "BlueprintGraph"});

        // Uncomment if you are using Slate UI
        PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

    }
}


MyProjectEditor.Build.cs


using UnrealBuildTool;
using System.IO;

public class MyProjectEditor : ModuleRules
{
    public MyProjectEditor(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        var EngineDir = Path.GetFullPath(Target.RelativeEnginePath);

        PublicIncludePaths.AddRange(new string] {
            "MyProjectEditor/Public"
        });

        PrivateIncludePaths.AddRange(new string] {
            "MyProjectEditor/Private",
             Path.Combine(EngineDir, @"Source/Developer/AssetTools/Private")
        });

        PublicDependencyModuleNames.AddRange(new string] { "MyProject"});

        PrivateDependencyModuleNames.AddRange(
            new string] 
            {
                "Core",
                "CoreUObject",
                "Engine",
                "AssetTools",
                "InputCore",
                "PropertyEditor",
                "Slate",
                "SlateCore",
                "EditorStyle",
                "MainFrame",
                "UnrealEd",
                "BlueprintGraph",
                "Kismet",
                "KismetCompiler",
                "GameplayTags",
                "RenderCore"
            });


        PrivateIncludePathModuleNames.AddRange(new string] { });

        DynamicallyLoadedModuleNames.AddRange(new string] { });

        if (Target.bBuildDeveloperTools || (Target.Configuration != UnrealTargetConfiguration.Shipping && Target.Configuration != UnrealTargetConfiguration.Test))
        {
            PrivateDependencyModuleNames.Add("GameplayDebugger");
            Definitions.Add("WITH_GAMEPLAY_DEBUGGER=1");
        }
        else
        {
            Definitions.Add("WITH_GAMEPLAY_DEBUGGER=0");
        }

    }
}

MyProjectTarget.cs


using UnrealBuildTool;
using System.Collections.Generic;

public class MyProjectTarget : TargetRules
{
    public MyProjectTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game;

        ExtraModuleNames.AddRange( new string] { "MyProject" } );

        if (bBuildEditor)
        {
            ExtraModuleNames.AddRange(new string] { "MyProjectEditor" });
        }
    }
}


MyProjectEditorTarget.cs


using UnrealBuildTool;
using System.Collections.Generic;

public class MyProjectEditorTarget : TargetRules
{
    public MyProjectEditorTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Editor;

        ExtraModuleNames.AddRange( new string] { "MyProject", "MyProjectEditor" } );
    }
}


[/SPOILER]

Can someone help me?

K2Node_GetSequenceBinding belongs to Editor module so you wont be able to package it.

It looks like you probably haven’t fully separated your custom node code into runtime/editor parts.

You need to remove the dependency on BlueprintGraph module from your main module build file, since it’s editor-only. Whatever code was dependent on that will then likely need to be moved either into your Editor module, or ideally to a new Developer-type module (if you put custom blueprint node stuff in an editor module, you’ll probably be able to package fine, but it might prevent your code from working in standalone game mode).

Thanks! That was the problem. I had one function that made a call to UEdGraphSchema_K2::IsPropertyExposedOnSpawn. Removing this call and the dependecy of “BlueprintGraph” in the MyProject.Build.cs solves the error.
After this, I also had to change in MyProjectTarget.cs



 if (bBuildEditor)
{
     ExtraModuleNames.AddRange(new string] { "MyProjectEditor" });
}


to



if (Target.Type == TargetType.Editor)
{
    ExtraModuleNames.AddRange(new string] { "MyProjectEditor" });
}