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:
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";
|
||||
|
||||
Reference in new issue
Block a user