Unity has changes how to create server build in 2021
replace:
if (serverBuild)
buildOptions |= BuildOptions.EnableHeadlessMode;with:
var options = new BuildPlayerOptions();
if (serverBuild)
options.subtarget = (int)(serverBuild ? StandaloneBuildSubtarget.Server : StandaloneBuildSubtarget.Player),UNITY_SERVER might now be defined in editor
replace:
#if UNITY_SERVERwith:
#if !UNITY_EDITOR && UNITY_SERVERreplace:
#if !UNITY_SERVERwith:
#if UNITY_EDITOR || !UNITY_SERVER