Error when trying to compile dedicated server binary

Hey everyone, I’m trying to compile a dedicated server binary by following the Dedicated Server Guide (A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums) on the wiki. Everything seems to go fine until I hit step 9, where I need to compile the actual Dedicated Server binary. At that point, VS Community 13 throws this error at me:

1>EXEC : error : Expecting to find a type to be declared in a module rules named ‘MyProject’ in MyProjectServerModuleRules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null. This type must derive from the ‘ModuleRules’ type defined by Unreal Build Tool.

I’m not VS savvy; the only reason I’m using it is to create a dedicated server. Any ideas what I’ve done wrong or what I’m missing?

Thanks!

I think you need a MyGameServer.Target.cs file, or make sure all the values inside it are set.

Something like this. notice the Type variable that I believe is what the error is referring to.

using UnrealBuildTool;
using System.Collections.Generic;

public class MyServerTarget : TargetRules
{
	public MyServerTarget(TargetInfo Target)
	{
		Type = TargetType.Server;
        bUsesSlate = false;
	}

	//
	// TargetRules interface.
	//

	public override bool GetSupportedPlatforms(ref List<UnrealTargetPlatform> OutPlatforms)
	{
		// It is valid for only server platforms
		return UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms(ref OutPlatforms, false);
	}

	public override void SetupBinaries(
		TargetInfo Target,
		ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
		ref List<string> OutExtraModuleNames
		)
	{        
		OutExtraModuleNames.Add("MyGame");
    }

    public override void SetupGlobalEnvironment(
        TargetInfo Target,
        ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
        ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
        )
    {
        // Turn on shipping logging, this will only apply to monolithic builds
        UEBuildConfiguration.bUseLoggingInShipping = true;
        UEBuildConfiguration.bCompileSteamOSS = false;
		UEBuildConfiguration.bCompileCEF3 = false;
    }
}

Additionally, there would be a MyGameServer.build.cs that looks something like this. Notice the ModuleRules class inheritance that I believe it mentioned in the error as well.

using UnrealBuildTool;

public class MyServer : ModuleRules
{
	public MyServer(TargetInfo Target)
	{
		PrivateIncludePaths.Add("../../MyGame/Source/MyServer/Private");

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

		PrivateDependencyModuleNames.AddRange(
			new string[] {
				"AssetRegistry",
				"OnlineSubsystem",
				"GameplayTags",
			}
		);

		DynamicallyLoadedModuleNames.AddRange(
			new string[] {
				// dependencies
			}
		);

		PrivateIncludePathModuleNames.AddRange(
			new string[] {
				// dependencies
			}
		);

        if (UEBuildConfiguration.bBuildEditor == true)
		{
			PrivateDependencyModuleNames.Add("UnrealEd");
		}

        if (Target.Configuration != UnrealTargetConfiguration.Shipping && Target.Configuration != UnrealTargetConfiguration.Test)
        {
            PrivateDependencyModuleNames.Add("GameplayDebugger");
        }

		if (UEBuildConfiguration.bCompileMcpOSS == true)
		{
			PrivateDependencyModuleNames.AddRange(
				new string[]
				{
					// dependencies
				}
			);
		}
	}
}

I see step #5 seems to address this, but maybe its a good time to go back over those steps.

Additionally, as a workaround, you can always run the editor as a server with -server, if you want to test things out and feel blocked by this.

I swapped out MyServer.Target.cs with the one you put in the comments, and I added the build.cs file as well (was missing that one entirely. Seems to be compiling now. Thanks!

what is this second code?i dont have!!!
and first code in site is deffrent to this and when i use it cant generation code

Hey mblogest-

Can you create a new post with detailed information about the specific issue you’re having? Please include the steps you’ve taken as well as any error message you receive to help identify the issue you’re having.

The error says “MyProject”

You are missing a file named MyProject.build.cs or inside that file you are using a different name other than MyProject.

 using UnrealBuildTool;
 
 public class MyProject: ModuleRules
 {
     public MyProject(TargetInfo Target)
...