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?

1 Like

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.

1 Like

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 @Eqric 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");
+		}
1 Like

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