GameServer.Target.cs Not Working

So, right now, I am trying to get a Dedicated Server running. I’ve downloaded the source version of 4.14 and everything went well with building it. I started a new C++ project and then packaged it. Then, I went in and added a Server.Target.cs file for my project with:


// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

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

//
// TargetRules interface.
//
public override void SetupBinaries(
    TargetInfo Target,
    ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
    ref List<string> OutExtraModuleNames
    )
{
    base.SetupBinaries(Target, ref OutBuildBinaryConfigurations, ref OutExtraModuleNames);
    OutExtraModuleNames.Add("Game");
}

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

public override List<UnrealTargetPlatform> GUBP_GetPlatforms_MonolithicOnly(UnrealTargetPlatform HostPlatform)
{
    if (HostPlatform == UnrealTargetPlatform.Mac)
    {
        return new List<UnrealTargetPlatform>();
    }
    return new List<UnrealTargetPlatform> { HostPlatform, UnrealTargetPlatform.Win32, UnrealTargetPlatform.Linux };
}

public override List<UnrealTargetConfiguration> GUBP_GetConfigs_MonolithicOnly(UnrealTargetPlatform HostPlatform, UnrealTargetPlatform Platform)
{
    return new List<UnrealTargetConfiguration> { UnrealTargetConfiguration.Development };
}

}


After that, I replaced the three instances in which it has the word Game and replaced it with the name of my project. I saved and then went to right click on my project again and clicked “Generate Visual Studio project files”. However, it stopped immediately and gave me this message in the log:


Running C:/Program Files (x86)/Epic Games/4.14/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“C:/Users/Ryan Brock/Documents/Unreal Projects/TrialRun/TrialRun.uproject” -game -rocket -progress
Discovering modules, targets and source code for project…
Messages while compiling C:\Users\Ryan Brock\Documents\Unreal Projects\TrialRun\Intermediate\Build\BuildRules\TrialRunModuleRules.dll:
c:\Users\Ryan Brock\Documents\Unreal Projects\TrialRun\Source\TrialRunServer.Target.cs(32,48) : error CS0115: ‘TrialRunServerTarget.GUBP_GetPlatforms_MonolithicOnly(UnrealBuildTool.UnrealTargetPlatform)’: no suitable method found to override
c:\Users\Ryan Brock\Documents\Unreal Projects\TrialRun\Source\TrialRunServer.Target.cs(41,53) : error CS0115: ‘TrialRunServerTarget.GUBP_GetConfigs_MonolithicOnly(UnrealBuildTool.UnrealTargetPlatform, UnrealBuildTool.UnrealTargetPlatform)’: no suitable method found to override
UnrealBuildTool Exception: ERROR: UnrealBuildTool encountered an error while compiling source files


I’ve fallowed all of the video and text guides that everyone has posted, but it still gives me the same error.

I have the same problem. Using 4.15, but had the same problem in 4.14.2

I have the same problem, same version of the UE4 (4.14.3). Have you found the solution?

Same problem. with the 4.15.

So, I deleted some of the code and it seems to work fine. Still need to test it with someone over internet but at least it builds and seems to work. I need to get home and I will tell exactly what to delete. Apparently the code that they have posted on the UE4 site is outdated and actually conflicts with some of the code in the newer source builds.

HI,
This function here has been depreciated:
public override bool GetSupportedPlatforms(ref List OutPlatforms)

If you take a look at the shooter game example there is an example config there. I just tested this and it works.

Here it is:
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

[SupportedPlatforms(UnrealPlatformClass.Server)]
public class ShooterGameServerTarget : TargetRules
{
	public ShooterGameServerTarget(TargetInfo Target)
	{
		Type = TargetType.Server;
		bUsesSteam = true;
	}

	//
	// TargetRules interface.
	//

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

Yeah I’ve deleted those line too and everything is working now :slight_smile:

I have the same problem.I use the same code,also can’t fix it.
When generate project files,there will be ERROR
ERROR: e:\UE4\Per\Source\PerServer.Target.cs(22,18) : error CS0122:
ERROR: e:\UE4\Per\Source\PerServer.Target.cs(20,26) : error CS0051:
ERROR: UnrealBuildTool Exception: Unable to compile source files.

I found working UE4GameServer.target.cs here , worked on the 4.20.

using UnrealBuildTool;
using System.Collections.Generic;

public class GenericShooterServerTarget : TargetRules
{
	public GenericShooterServerTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Server;

		ExtraModuleNames.Add("UE4Game"); // This would be your project module if not BP only
	}

	//
	// TargetRules interface.
	//

	public override void SetupGlobalEnvironment(
		TargetInfo Target,
		ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
		ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
		)
	{
	}
}

I really have a Bad time with this problem :frowning: … any real solution for it until now ue4 4.22?

Unreal is constantly changing, so the current version of the file (4.24.3) according to their shooter game tamplate should be this:

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

[SupportedPlatforms(UnrealPlatformClass.Server)]
public class ShooterServerTarget : TargetRules
{
	public ShooterServerTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Server;
		bUsesSteam = true;

		ExtraModuleNames.Add("ShooterGame");
	}
}