Build a windows service on windows server you need to compile the assemblies with win-x64 runtime
dotnet build -c Release --runtime win-x64 --no-self-contained
dotnet publish-c Release --runtime win-x64 --no-self-contained
use sc.exe util to install the windows service
sc.exe create "ServiceName" binpath="Dir\Service.exe"
info: