diff --git a/src/Titano.Server/Hosting/Windows/ServiceInstaller.cs b/src/Titano.Server/Hosting/Windows/ServiceInstaller.cs index 7d3adc8f..375fa13e 100644 --- a/src/Titano.Server/Hosting/Windows/ServiceInstaller.cs +++ b/src/Titano.Server/Hosting/Windows/ServiceInstaller.cs @@ -75,7 +75,8 @@ public static unsafe class ServiceInstaller private static string CommandLine() { var process = Environment.ProcessPath ?? throw new InvalidOperationException("The executable path is unknown."); - var assembly = typeof(ServiceInstaller).Assembly.Location; + // Assembly.Location is empty in a single-file app; under dotnet the entry assembly sits in the base directory. + var assembly = Path.Combine(AppContext.BaseDirectory, typeof(ServiceInstaller).Assembly.GetName().Name + ".dll"); return Path.GetFileNameWithoutExtension(process).Equals("dotnet", StringComparison.OrdinalIgnoreCase) ? $"\"{process}\" \"{assembly}\" --service" : $"\"{process}\" --service";