下面代码是官方ShooterGame的UE4 v4.11版本(其实和4.1.0没有差别)。
ShooterGameServer.Target.cs
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. using UnrealBuildTool; using System.Collections.Generic; public class ShooterGameServerTarget : TargetRules { public ShooterGameServerTarget(TargetInfo Target) { Type = TargetType.Server; bUsesSteam = true; } // // 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("ShooterGame"); } public override List<UnrealTargetPlatform> GUBP_GetPlatforms_MonolithicOnly(UnrealTargetPlatform HostPlatform) { List<UnrealTargetPlatform> Platforms = null; switch (HostPlatform) { case UnrealTargetPlatform.Linux: Platforms = new List<UnrealTargetPlatform> { HostPlatform }; break; case UnrealTargetPlatform.Win64: Platforms = new List<UnrealTargetPlatform> { HostPlatform, UnrealTargetPlatform.Linux }; break; default: Platforms = new List<UnrealTargetPlatform>(); break; } return Platforms; } public override List<UnrealTargetConfiguration> GUBP_GetConfigs_MonolithicOnly(UnrealTargetPlatform HostPlatform, UnrealTargetPlatform Platform) { return new List<UnrealTargetConfiguration> { UnrealTargetConfiguration.Test }; } public override List<GUBPFormalBuild> GUBP_GetConfigsForFormalBuilds_MonolithicOnly(UnrealTargetPlatform HostPlatform) { return new List<GUBPFormalBuild>(); } }