You can create a Dedicated Server build in either of the following ways:
To create a Dedicated Server build in the Unity Editor, use the following steps:
Tip: You can further configure the Dedicated Server build in the Player settingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary.
To create a Dedicated Server build using a script, set buildPlayerOptions.subtarget to (int)StandaloneBuildSubtarget.Server.
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
// SubTarget expects an integer.
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
Unity defines the UNITY_SERVER scripting symbol when you build for the Dedicated Server platform. You can use this symbol in your scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary to compile code for the server. For more information, refer to Scripting symbol reference.
To create a Dedicated Server build through the command line, use the -standaloneBuildSubtarget Server argument.
-buildTarget Linux64 -standaloneBuildSubtarget Server
A Dedicated Server build is a headless executable with no graphical interface. To interact with and configure your server application at runtime, use the Unity Player command line arguments and the DedicatedServer.Arguments API.
Dedicated Server builds that aren’t code signed might display security warnings when deployed on macOS systems. To avoid such warnings, make sure you code sign the build before distribution. For more information, refer to the documentation on Code sign and notarize your macOS application.