You Should Have.Target.cs Files



This document covers the bare basics on how to get your Unreal Engine 4 game project able to build both Windows and Linux dedicated server builds, using just a Windows machine for compiling.



Visual Studio Community Edition 2013 is required for 4.9.X and older.



Visual Studio Community Edition 2015 is required to upgrade to 4.10 or later.



Unreal Engine 4 compiled with source code



A Tutorial I wrote on how to do this Epic's Documentation on how to do this



Project must be C++ code



If your project is a Blueprint Only, you can follow this tutorial to wrap the project in C++. Don't worry, you won't have to write any code.



Linux Toolchain for Windows installed for Linux x86 Server Support



You can find this link in my beginner's guide. There is also the UE4 Wiki documentation



Adding Dedicated Server Support



Note: The word Project in any referenced file name or code will refer to your project's name. For example, my project for this tutorial is named GenShooter, so in my case Project.Target.cs refers to GenShooter.Target.cs. In my case, ProjectTarget is GenShooterTarget.



1. Navigate to the Source folder of your Project. You should see some .Target.cs files.



2. Make a copy of Project.Target.cs file and rename it ProjectServer.Target.cs, be sure not to grab ProjectEditor.Target.cs.



3. Open up ProjectServer.Target.cs in your favorite text editor. Visual Studio is the tool I'll use here. 4. Rename all instances ProjectTarget instances to ProjectServerTarget. 5. Change Type = TargetType.Game. To Type = TargetType.Server. 6. Save this file. Your ProjectServer.Target.cs file should look something like this now:



Building your Dedicated Server



1. Right-click on the.uproject file for your project in your folder and choose "Generate Visual Studio project documents".



2. Now, we will need to build our project using Visual Studio with the Development Server configuration on the Windows platform. This is also applicable for the Linux platform if you have the Linux x86 Cross-Compile Toolchain installed. To do this, build your game project just as we built it in the past tutorials but this time with the Development Server build configuration.



After the Windows server is built, you should see this output.



Here is the output for the Linux Server.



Now your project supports building for dedicated servers, for all platforms, including Linux. Whether Linux compiles depends on how well your Linux x86 Cross-Compile Toolchain has been set up.



Packaging Your Dedicated Server



1. Open up your project in UE4Editor. 2. Use Window -> Project Launcher to open the Project Launcher.



This window should greet you with this view.



This window allows for the launch of various configurations for project deployment.



1. A custom build profile is required to build your project on dedicated server form. Click the "Add a new custom launch profile" button in the bottom panel that looks like a plus sign. This will bring up the custom profile editing screen.



1. Choose your Project in the Project drop down. If you do not see it, click browse and feed it your project's .uproject file.



1. Change Cook mode from On the Fly to By the Book. Select the WindowsServer platform in Cooked platforms. If you have the Linux x86 Cross-Compile Toolchain installed, select the LinuxServer platform. If your project is not English-centric, you can also select en under Cooked Cultures or your base language. These settings can be viewed by clicking here



1. Change Package mode from Do not package to Package & store locally. Leave all the settings in here blank by default.



1. Change the deployment mode to not deploy



1. To return to Project Launcher Window main page, click "Back", in the upper right. 2. Click the "Launch This Profile button next to your custom profile. This button is similar to the Play button within the level editor window.



1. This will begin the process of cooking and packaging your dedicated servers for your selected platforms. This process can take a while. It should look like this once it is complete.



Locating your dedicated server build



After you have packaged your dedicated servers builds, you will find them in the SavedStagedBuild directory. If you have packaged your regular game builds, you'll see them listed here as WindowsNoEditor and LinuxNoEditor as well. You are free to copy these builds to your target machines and distribute them as you like.



Important Notes about the Windows Dedicated Server



When you load Windows Dedicated Server, it will appear that nothing is loading up and that there is no UI/command prompt. You will be able to see that your server actually is running by opening Windows Task Manager. You can view the log output from your Windows Dedicated Server by running it with the log argument. This is the easiest way:



1. Hold Shift and Right-click the folder your Windows Dedicated Server is in and choose "Open command window here."



1. Enter ProjectServer.exe-log and hit Enter.WEBARCHIVE This is GenShooterServer.exe.log in my case.

150 Views