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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 13:35:28 +00:00
1 parent f4e2f285a9
commit 3cb94612c0
1 file changed
+2 -1
@@ -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";