How to package the game with Server Target setting?

When I choose the Windows (Server) Target, the game packages as a Game and not as a Server in UE5. has anyone an idea how I can package my game for an dedicated server?

2 Likes

I am having the same problem, did you found a solution?

Sadly not :frowning:

I solved it using an ugly hack.

In TurnkeySupportModule.cpp at row 479 i added this following:
BuildCookRunParams += TEXT(" -dedicatedserver");

It seems to have fixed it tho i don’t know if this is will destroy something else or not. So far it seems to be working fine for me.

2 Likes

Oh nice! Do I need to do something else? Compiling it again?

Should be enough to compile the engine. :slight_smile:

FYI: This worked for a default Third Person Blueprint project to do a server build.
However when trying to do the client build I get this error (I was able to overcome it by using the binary version of UE5 to build the client):
Assertion failed: !Export.TemplateIndex.IsNull() [File:C:/Projects/UnrealEngine-UE5/Engine/Source/Runtime/CoreUObject/Private/Serialization/AsyncLoading2.cpp] [Line: 3530]
0x00007ff75e330bef UnrealGame.exe!UnknownFunction []
0x00007ff75e33d5f3 UnrealGame.exe!UnknownFunction []
0x00007ff75e3411ab UnrealGame.exe!UnknownFunction []
0x00007ff75e3587cb UnrealGame.exe!UnknownFunction []
0x00007ff75e374f4c UnrealGame.exe!UnknownFunction []
0x00007ff75e25b55b UnrealGame.exe!UnknownFunction []
0x00007ff75e256fd7 UnrealGame.exe!UnknownFunction []
0x00007ff961e27034 KERNEL32.DLL!UnknownFunction []
0x00007ff962182651 ntdll.dll!UnknownFunction []
Crash in runnable thread FAsyncLoadingThread

I assume to do a C++ build we need to follow all these steps still?

Actually this doesn’t work because the build versions are different and throw an error:
NotifyControlMessage: Client connecting with invalid version. LocalNetworkVersion: -1710349547, RemoteNetworkVersion: 373453439

So back to the issue of the Windows build throwing this runtime error?
Assertion failed: !Export.TemplateIndex.IsNull() [File:C:/Projects/UnrealEngine-UE5/Engine/Source/Runtime/CoreUObject/Private/Serialization/AsyncLoading2.cpp]

I am also having the same issue.
I tried doing this step: “In TurnkeySupportModule.cpp at row 479 i added this following:
BuildCookRunParams += TEXT(” -dedicatedserver");"
But to no avail even after recompiling the engine. Does it require a full rebuild of the engine?

I’m guessing your symptom is “the game still launches a GUI”?

I believe the instructions from @Fronit should be updated to also include the -noclient argument. Here are my changes that gets me a headless dedicated server (which uses -server instead of -dedicatedserver; they are aliases):

diff --git a/Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp b/Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp
index 3012d89db5162..ecece2f759d3a 100644
--- a/Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp
+++ b/Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp
@@ -79,12 +79,14 @@ FTargetPlatformInfo::FTargetPlatformInfo(const FString& InIniPlatformName, EBuil
 		// put the type in parens
 		DisplayString += FString::Printf(TEXT(" (%s)"), LexToString(PlatformType));
 
-		// client builds need to be plopped on the commandline, servers are handled differently? 
-		// @todo: not sure if needed to be handled specially, honestly
 		if (PlatformType == EBuildTargetType::Client)
 		{
 			UATCommandLine += TEXT(" -client");
 		}
+		else if (PlatformType == EBuildTargetType::Server)
+		{
+			UATCommandLine += TEXT(" -server -noclient");
+		}
 
 		VanillaInfo->Flavors.AddUnique(this);
 	}
5 Likes

I’m not sure what your issue is here, but mixing between the prebuilt UE5 and a self-compiled UE5 will not work (as you have found out).

I have not seen the error you’re having with building the client. Make sure you have the latest ue5-early-access code (do a pull to be sure). As an aside, if you’re using the ue5-main branch, there’s just no guarantees from Epic that it’ll compile at any point of time haha. Outside of that, it’s hard to tell why you’re having compilation errors with your client builds

Where is this cpp files?

You should use the solution provided by IncantaGames instead and the file for that is located at /Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp

How to use this cpp?

You need to open the /Engine/Source/Developer/DesktopPlatform/Private/PlatformInfo.cpp file in your UnrealEngine source folder, where ever you put that. From there see the lines deleted and added in my patch notes in my prior comment here and make the same edits to your own version. Primarily, you need to add the else if ... statement. After this, build the engine source again in Visual Studio.

I mean no offense at all by this, but if you don’t know how to do proceed with these steps, I’m not sure I would recommend using UE5 with a server target and stick with UE4. This isn’t necessarily an advanced edit, and you may have significantly harder challenges ahead.

1 Like

I had add the code in line 479 of TurnkeySupportModule.cpp only. it can packet server program. But the code mad it packet 2 target(one is server and other is game)if i select windows(server). I guess that the code BuildCookRunParams += TEXT(” -dedicatedserver");” is add a new target behind the originally wrong target,so packet is run 2 times. So I can make my server packet(although it has been packeted twice, but I can still accept the waste of time). But I had see you say the other CPP:PlatformInfo.cpp, I don`t know what is it work. So I ask you.

I don’t fully understand your problem, but instead of having the changes in TurnkeySupportModule.cpp suggested by @Fronit, revert those changes and follow my instructions for PlatformInfo.cpp in my comment: How to package the game with Server Target setting? - #11 by IncantaGames

1 Like

Why add code why not just fix it, nothing here is correct by the way.

I have the same problem here… Any real solution or explanation ?

This issue is now fixed in UE 5.0 Github branch and will likely be part of the next preview/release: https://github.com/EpicGames/UnrealEngine/commit/a61147c2f8dc9903553c942e20dbe1f86f0febce (although you’ll be building from source if you’re using dedicated servers)