From 3cb94612c081efb6fe1c4be5ebfb14273cb871d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 13:35:28 +0000 Subject: [PATCH] fix(server): service command line works in a single-file publish Assembly.Location is empty in a single-file app (IL3000 failed the Windows publish step); the entry assembly path now comes from the base directory, which is where it lives when the server runs under dotnet. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- src/Titano.Server/Hosting/Windows/ServiceInstaller.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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";