From d92536b707d1edb30987ca77c31215fb26823c2c Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 22 Dec 2024 10:22:45 +0100 Subject: [PATCH] Allow net6.0 releases / Support single file deployment (#487) * allow .net6.0 releases * support single file deployment e2e --- src/Runner.Client/Program.cs | 43 ++++++++++++---- src/Runner.Client/Runner.Client.csproj | 17 ++++++- src/Runner.Client/WrapProcService.cs | 26 +++++++--- src/Runner.Common/HostContext.cs | 9 +++- src/Runner.Common/Runner.Common.csproj | 12 ++++- .../Configuration/ConfigurationManager.cs | 29 ++++++----- src/Runner.Listener/JobDispatcher.cs | 21 +++++--- src/Runner.Listener/Program.cs | 2 +- src/Runner.Listener/Runner.Listener.csproj | 13 ++++- .../Runner.PluginHost.csproj | 3 +- src/Runner.Plugins/Runner.Plugins.csproj | 3 +- src/Runner.Sdk/GharunUtil.cs | 18 +++++++ src/Runner.Sdk/Runner.Sdk.csproj | 13 ++++- src/Runner.Server/Program.cs | 11 +++-- src/Runner.Server/Runner.Server.csproj | 49 ++++++++++++++----- src/Runner.Server/Startup.cs | 23 +++++++-- .../Windows/RunnerService.csproj | 9 +++- src/Runner.Worker/Runner.Worker.csproj | 11 ++++- src/Runner.Worker/RunnerPluginManager.cs | 29 ++++++----- src/Sdk/Sdk.csproj | 16 ++++-- 20 files changed, 269 insertions(+), 88 deletions(-) diff --git a/src/Runner.Client/Program.cs b/src/Runner.Client/Program.cs index ed1271db04d..00886f639c1 100644 --- a/src/Runner.Client/Program.cs +++ b/src/Runner.Client/Program.cs @@ -271,11 +271,13 @@ private static async Task CreateRunner(string binpath, Parameters parameter #else string ext = IOUtil.ExeExtension; #endif - var runner = Path.Join(binpath, $"Runner.Listener{ext}"); + var runner = string.IsNullOrWhiteSpace(binpath) ? Environment.ProcessPath : Path.Join(binpath, $"Runner.Listener{ext}"); var file = runner; + if(!string.IsNullOrWhiteSpace(binpath)) { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - file = dotnet; + file = dotnet; #endif + } var agentname = Path.GetRandomFileName(); string tmpdir = Path.Combine(Path.GetFullPath(parameters.RunnerDirectory), agentname); Directory.CreateDirectory(tmpdir); @@ -320,10 +322,12 @@ private static async Task CreateRunner(string binpath, Parameters parameter runnerEnv["RUNNER_CONTAINER_KEEP"] = "1"; } - var arguments = $"Configure --name {agentname} --unattended --url {parameters.Server}/runner/server --token {parameters.Token ?? "empty"} --labels container-host --work w"; + var arguments = $"configure --name {agentname} --unattended --url {parameters.Server}/runner/server --token {parameters.Token ?? "empty"} --labels container-host --work w"; + if(!string.IsNullOrWhiteSpace(binpath)) { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - arguments = $"\"{runner}\" {arguments}"; + arguments = $"\"{runner}\" {arguments}"; #endif + } var code = await inv.ExecuteAsync(binpath, file, arguments, runnerEnv, true, null, true, CancellationTokenSource.CreateLinkedTokenSource(source.Token, new CancellationTokenSource(60 * 1000).Token).Token); int execAttempt = 1; @@ -348,10 +352,12 @@ private static async Task CreateRunner(string binpath, Parameters parameter if(source.IsCancellationRequested) { return 1; } - arguments = $"Run{(parameters.KeepContainer || parameters.NoReuse ? " --once" : "")}"; - #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - arguments = $"\"{runner}\" {arguments}"; - #endif + arguments = $"run{(parameters.KeepContainer || parameters.NoReuse ? " --once" : "")}"; + if(!string.IsNullOrWhiteSpace(binpath)) { +#if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 + arguments = $"\"{runner}\" {arguments}"; +#endif + } await runnerlistener.ExecuteAsync(binpath, file, arguments, runnerEnv, true, null, true, runToken.Token); break; } @@ -553,13 +559,18 @@ private static async Task CreateExternalRunner(string binpath, Parameters p // Wrap listener to avoid that ctrl-c is sent to the runner if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { + if(string.IsNullOrWhiteSpace(binpath)) { + arguments = $"spawn \"{file}\" {arguments}"; + file = Environment.ProcessPath; + } else { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 arguments = $"\"{Path.Join(binpath, "Runner.Client.dll")}\" spawn \"{file}\" {arguments}"; file = Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); #else - arguments = $"spawn \"{file}\" {arguments}"; - file = Path.Join(binpath, $"Runner.Client{ext}"); + arguments = $"spawn \"{file}\" {arguments}"; + file = Path.Join(binpath, $"Runner.Client{ext}"); #endif + } } ((Func)(async () => { @@ -979,6 +990,18 @@ static int Main(string[] args) Runner.Server.Program.Main(args.Skip(1).ToArray()); return 0; } + if(args.Length > 0 && (args[0] == "configure" || args[0] == "run" || args[0] == "remove")) { + GitHub.Runner.Listener.Program.Main(args); + return 0; + } + if(args.Length > 0 && args[0] == "spawnclient") { + GitHub.Runner.Worker.Program.Main(args); + return 0; + } + if(args.Length > 0 && args[0] == "action") { + GitHub.Runner.PluginHost.Program.Main(args); + return 0; + } if(System.OperatingSystem.IsWindowsVersionAtLeast(10)) { WindowsUtils.EnableVT(); } diff --git a/src/Runner.Client/Runner.Client.csproj b/src/Runner.Client/Runner.Client.csproj index cd9b9b3be58..785b324a22b 100644 --- a/src/Runner.Client/Runner.Client.csproj +++ b/src/Runner.Client/Runner.Client.csproj @@ -14,7 +14,8 @@ true ./nupkg Exe - net8.0 + net8.0 + net6.0 win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 NU5118;NU5123;NU5119;NU1701;NU1603;CS4014 Christopher Homberger @@ -22,6 +23,8 @@ Unofficial GitHub Actions Runner Client, run your github action workflows locally. $(CHANGELOG_LINE)More Information https://github.com/ChristopherHX/runner.server. MIT https://github.com/ChristopherHX/runner.server + + false @@ -30,13 +33,23 @@ - + PreserveNewest + + + PreserveNewest + + + Always + + + + diff --git a/src/Runner.Client/WrapProcService.cs b/src/Runner.Client/WrapProcService.cs index 0c741d04172..6bf338c00f4 100644 --- a/src/Runner.Client/WrapProcService.cs +++ b/src/Runner.Client/WrapProcService.cs @@ -77,13 +77,18 @@ public Task ExecuteAsync(string workingDirectory, string fileName, string a var binpath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); fileName = Path.Join(_context.GetDirectory(WellKnownDirectory.ConfigRoot), "bin", $"{queue.Prefix}.Worker{queue.Suffix}"); arguments = i == -1 ? arguments : arguments.Substring(i); + if(string.IsNullOrWhiteSpace(binpath)) { + arguments = $"spawn \"{fileName}\" {arguments}"; + fileName = Environment.ProcessPath; + } else { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - arguments = $"\"{Path.Join(binpath, "Runner.Client.dll")}\" spawn \"{fileName}\" {arguments}"; - fileName = Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); + arguments = $"\"{Path.Join(binpath, "Runner.Client.dll")}\" spawn \"{fileName}\" {arguments}"; + fileName = Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); #else - arguments = $"spawn \"{fileName}\" {arguments}"; - fileName = Path.Join(binpath, $"Runner.Client{IOUtil.ExeExtension}"); + arguments = $"spawn \"{fileName}\" {arguments}"; + fileName = Path.Join(binpath, $"Runner.Client{IOUtil.ExeExtension}"); #endif + } return org.ExecuteAsync(workingDirectory, fileName, arguments, environment, requireExitCodeZero, outputEncoding, killProcessOnCancel, redirectStandardIn, inheritConsoleHandler, keepStandardInOpen, highPriorityProcess, cancellationToken); } else { return org.ExecuteAsync(workingDirectory, Path.Join(_context.GetDirectory(WellKnownDirectory.ConfigRoot), "bin", $"{queue.Prefix}.Worker{queue.Suffix}"), i == -1 ? arguments : arguments.Substring(i), environment, requireExitCodeZero, outputEncoding, killProcessOnCancel, redirectStandardIn, inheritConsoleHandler, keepStandardInOpen, highPriorityProcess, cancellationToken); @@ -92,13 +97,18 @@ public Task ExecuteAsync(string workingDirectory, string fileName, string a if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { var binpath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + if(string.IsNullOrWhiteSpace(binpath)) { + arguments = $"spawn \"{fileName}\" {arguments}"; + fileName = Environment.ProcessPath; + } else { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - arguments = $"\"{Path.Join(binpath, "Runner.Client.dll")}\" spawn \"{fileName}\" {arguments}"; - fileName = Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); + arguments = $"\"{Path.Join(binpath, "Runner.Client.dll")}\" spawn \"{fileName}\" {arguments}"; + fileName = Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); #else - arguments = $"spawn \"{fileName}\" {arguments}"; - fileName = Path.Join(binpath, $"Runner.Client{IOUtil.ExeExtension}"); + arguments = $"spawn \"{fileName}\" {arguments}"; + fileName = Path.Join(binpath, $"Runner.Client{IOUtil.ExeExtension}"); #endif + } return org.ExecuteAsync(workingDirectory, fileName, arguments, new Dictionary() { {"RUNNER_SERVER_CONFIG_ROOT", _context.GetDirectory(WellKnownDirectory.ConfigRoot)} }, requireExitCodeZero, outputEncoding, killProcessOnCancel, redirectStandardIn, inheritConsoleHandler, keepStandardInOpen, highPriorityProcess, cancellationToken); } return org.ExecuteAsync(workingDirectory, fileName, arguments, new Dictionary() { {"RUNNER_SERVER_CONFIG_ROOT", _context.GetDirectory(WellKnownDirectory.ConfigRoot)} }, requireExitCodeZero, outputEncoding, killProcessOnCancel, redirectStandardIn, inheritConsoleHandler, keepStandardInOpen, highPriorityProcess, cancellationToken); diff --git a/src/Runner.Common/HostContext.cs b/src/Runner.Common/HostContext.cs index 93b5e39d8cb..05e3a73a96f 100644 --- a/src/Runner.Common/HostContext.cs +++ b/src/Runner.Common/HostContext.cs @@ -281,6 +281,9 @@ public string GetDirectory(WellKnownDirectory directory) { case WellKnownDirectory.Bin: path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + if(path == null) { + path = AppContext.BaseDirectory; + } break; case WellKnownDirectory.Diag: @@ -304,7 +307,11 @@ public string GetDirectory(WellKnownDirectory directory) break; case WellKnownDirectory.Root: - path = new DirectoryInfo(GetDirectory(WellKnownDirectory.Bin)).Parent.FullName; + if(string.IsNullOrWhiteSpace(Assembly.GetEntryAssembly().Location)) { + path = AppContext.BaseDirectory; + } else { + path = new DirectoryInfo(GetDirectory(WellKnownDirectory.Bin)).Parent.FullName; + } break; case WellKnownDirectory.ConfigRoot: diff --git a/src/Runner.Common/Runner.Common.csproj b/src/Runner.Common/Runner.Common.csproj index efe270ab003..6486574130d 100644 --- a/src/Runner.Common/Runner.Common.csproj +++ b/src/Runner.Common/Runner.Common.csproj @@ -1,7 +1,8 @@  - net8.0 + net8.0 + net6.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true @@ -18,11 +19,20 @@ + + + + + + + + + portable diff --git a/src/Runner.Listener/Configuration/ConfigurationManager.cs b/src/Runner.Listener/Configuration/ConfigurationManager.cs index 615ae605dbf..456306660b3 100644 --- a/src/Runner.Listener/Configuration/ConfigurationManager.cs +++ b/src/Runner.Listener/Configuration/ConfigurationManager.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Net.Http; using System.Net.Http.Headers; +using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; @@ -420,20 +421,22 @@ public async Task ConfigureAsync(CommandSettings command) _term.WriteSuccessMessage("Settings Saved."); _term.WriteLine(); - if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { - // config windows service - bool runAsService = command.GetRunAsService(); - if (runAsService) - { - Trace.Info("Configuring to run the agent as service"); - var serviceControlManager = HostContext.GetService(); - serviceControlManager.ConfigureService(runnerSettings, command); - } + if(!string.IsNullOrWhiteSpace(Assembly.GetExecutingAssembly().Location)) { + if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { + // config windows service + bool runAsService = command.GetRunAsService(); + if (runAsService) + { + Trace.Info("Configuring to run the agent as service"); + var serviceControlManager = HostContext.GetService(); + serviceControlManager.ConfigureService(runnerSettings, command); + } - } else if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux) || System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) { - // generate service config script for OSX and Linux, GenerateScripts() will no-opt on windows. - var serviceControlManager = HostContext.GetService(); - serviceControlManager.GenerateScripts(runnerSettings); + } else if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux) || System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) { + // generate service config script for OSX and Linux, GenerateScripts() will no-opt on windows. + var serviceControlManager = HostContext.GetService(); + serviceControlManager.GenerateScripts(runnerSettings); + } } } diff --git a/src/Runner.Listener/JobDispatcher.cs b/src/Runner.Listener/JobDispatcher.cs index d017ecd5226..982a78cbfa3 100644 --- a/src/Runner.Listener/JobDispatcher.cs +++ b/src/Runner.Listener/JobDispatcher.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -465,18 +466,24 @@ private async Task RunAsync(Pipelines.AgentJobRequestMessage message, string orc // Start the child process. HostContext.WritePerfCounter("StartingWorkerProcess"); var assemblyDirectory = HostContext.GetDirectory(WellKnownDirectory.Bin); + var binpath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + string arguments = "spawnclient " + pipeHandleOut + " " + pipeHandleIn; + string workerFileName; + if(string.IsNullOrWhiteSpace(binpath)) { + workerFileName = Environment.ProcessPath; + } else { #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - string ext = ".dll"; + string ext = ".dll"; #else - string ext = IOUtil.ExeExtension; + string ext = IOUtil.ExeExtension; #endif - string workerFileName = Path.Combine(assemblyDirectory, $"{_workerProcessName}{ext}"); - string arguments = "spawnclient " + pipeHandleOut + " " + pipeHandleIn; + workerFileName = Path.Combine(assemblyDirectory, $"{_workerProcessName}{ext}"); #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - var dotnet = global::Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); - arguments = $"\"{workerFileName}\" {arguments}"; - workerFileName = dotnet; + var dotnet = global::Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); + arguments = $"\"{workerFileName}\" {arguments}"; + workerFileName = dotnet; #endif + } workerProcessTask = processInvoker.ExecuteAsync( workingDirectory: assemblyDirectory, fileName: workerFileName, diff --git a/src/Runner.Listener/Program.cs b/src/Runner.Listener/Program.cs index 2dbe6b32db4..ed844c869e6 100644 --- a/src/Runner.Listener/Program.cs +++ b/src/Runner.Listener/Program.cs @@ -176,7 +176,7 @@ private async static Task MainAsync(IHostContext context, string[] args) private static void LoadAndSetEnv() { var binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - var rootDir = new DirectoryInfo(binDir).Parent.FullName; + var rootDir = string.IsNullOrWhiteSpace(binDir) ? AppContext.BaseDirectory : new DirectoryInfo(binDir).Parent.FullName; string envFile = Path.Combine(rootDir, ".env"); if (File.Exists(envFile)) { diff --git a/src/Runner.Listener/Runner.Listener.csproj b/src/Runner.Listener/Runner.Listener.csproj index 2ab7a45dcce..03139345ec5 100644 --- a/src/Runner.Listener/Runner.Listener.csproj +++ b/src/Runner.Listener/Runner.Listener.csproj @@ -1,7 +1,8 @@  - net8.0 + net8.0 + net6.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true @@ -21,9 +22,17 @@ + + + + - + + + + + diff --git a/src/Runner.PluginHost/Runner.PluginHost.csproj b/src/Runner.PluginHost/Runner.PluginHost.csproj index b4a6f5f2205..a84dea62200 100644 --- a/src/Runner.PluginHost/Runner.PluginHost.csproj +++ b/src/Runner.PluginHost/Runner.PluginHost.csproj @@ -1,7 +1,8 @@  - net8.0 + net8.0 + net6.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true diff --git a/src/Runner.Plugins/Runner.Plugins.csproj b/src/Runner.Plugins/Runner.Plugins.csproj index fa9ec8bffce..85ca8273ebc 100644 --- a/src/Runner.Plugins/Runner.Plugins.csproj +++ b/src/Runner.Plugins/Runner.Plugins.csproj @@ -1,7 +1,8 @@  - net8.0 + net8.0 + net6.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true diff --git a/src/Runner.Sdk/GharunUtil.cs b/src/Runner.Sdk/GharunUtil.cs index 7f496daa87d..e523c4d2868 100644 --- a/src/Runner.Sdk/GharunUtil.cs +++ b/src/Runner.Sdk/GharunUtil.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Reflection; +using Newtonsoft.Json; namespace GitHub.Runner.Sdk { public class GharunUtil { @@ -8,7 +9,24 @@ private static bool IsUsableLocalStorage(string localStorage) { return localStorage != "" && !localStorage.Contains(' ') && !localStorage.Contains('"') && !localStorage.Contains('\''); } + private class PortableConfig { + public string StoragePath { get; set; } + } + + private static PortableConfig ExeConfig { get; set; } + private static string GetLocalStorageLocation(string name) { + var portableConfig = Environment.ProcessPath + ".portable.config"; + if(ExeConfig == null) { + if(File.Exists(portableConfig)) { + ExeConfig = JsonConvert.DeserializeObject(File.ReadAllText(portableConfig)); + } else { + ExeConfig = new PortableConfig(); + } + } + if(!string.IsNullOrWhiteSpace(ExeConfig?.StoragePath)) { + return Path.GetFullPath(ExeConfig.StoragePath); + } var localStorage = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); if(!IsUsableLocalStorage(localStorage)) { localStorage = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); diff --git a/src/Runner.Sdk/Runner.Sdk.csproj b/src/Runner.Sdk/Runner.Sdk.csproj index 4f18d839e66..c87a65e48b1 100644 --- a/src/Runner.Sdk/Runner.Sdk.csproj +++ b/src/Runner.Sdk/Runner.Sdk.csproj @@ -1,7 +1,8 @@  - net8.0 + net8.0 + net6.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true @@ -15,11 +16,19 @@ - + + + + + + + + + portable diff --git a/src/Runner.Server/Program.cs b/src/Runner.Server/Program.cs index 7bbaef404e5..4f9c95249bc 100644 --- a/src/Runner.Server/Program.cs +++ b/src/Runner.Server/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Reflection; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration.EnvironmentVariables; @@ -38,10 +39,12 @@ public static IHostBuilder CreateHostBuilder(string[] args) => { webBuilder.UseStartup(); var contentRoot = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - var wwwRoot = System.IO.Path.Combine(contentRoot, "wwwroot"); - if(System.IO.Directory.Exists(contentRoot) && System.IO.Directory.Exists(wwwRoot)) { - webBuilder.UseContentRoot(contentRoot); - webBuilder.UseWebRoot(wwwRoot); + if(contentRoot != null) { + var wwwRoot = System.IO.Path.Combine(contentRoot, "wwwroot"); + if(System.IO.Directory.Exists(contentRoot) && System.IO.Directory.Exists(wwwRoot)) { + webBuilder.UseContentRoot(contentRoot); + webBuilder.UseWebRoot(wwwRoot); + } } var RUNNER_SERVER_APP_JSON_SETTINGS_FILE = Environment.GetEnvironmentVariable("RUNNER_SERVER_APP_JSON_SETTINGS_FILE"); if(RUNNER_SERVER_APP_JSON_SETTINGS_FILE != null) { diff --git a/src/Runner.Server/Runner.Server.csproj b/src/Runner.Server/Runner.Server.csproj index 17947bea57f..6ea12509ddf 100644 --- a/src/Runner.Server/Runner.Server.csproj +++ b/src/Runner.Server/Runner.Server.csproj @@ -2,10 +2,12 @@ Exe - net8.0 + net8.0 + net6.0 NU1701;NU1603;NU1605;CS4014 win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 false + true @@ -13,6 +15,19 @@ + + + + + + + + + + + + + @@ -22,21 +37,25 @@ - - - - - - - - - - + + + + + + + + + + + + + + @@ -45,10 +64,18 @@ Runner.Server.localcheckout_template.yml + + + + + + + + quartz/tables_sqlite.sql diff --git a/src/Runner.Server/Startup.cs b/src/Runner.Server/Startup.cs index 662beabc347..8cd3c73f30a 100644 --- a/src/Runner.Server/Startup.cs +++ b/src/Runner.Server/Startup.cs @@ -399,11 +399,24 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApp app.UseRewriter(rewriteOptions); } - DefaultFilesOptions options = new DefaultFilesOptions(); - options.DefaultFileNames.Clear(); - options.DefaultFileNames.Add("index.html"); - app.UseDefaultFiles(options); - app.UseStaticFiles(); + if(string.IsNullOrEmpty(Assembly.GetEntryAssembly().Location)) { + var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot"); + + DefaultFilesOptions options = new DefaultFilesOptions(); + options.DefaultFileNames.Clear(); + options.DefaultFileNames.Add("index.html"); + options.FileProvider = fileProvider; + options.RequestPath = string.Empty; + app.UseDefaultFiles(options); + + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = fileProvider, + RequestPath = string.Empty, + }); + } else { + app.UseStaticFiles(); + } } } diff --git a/src/Runner.Service/Windows/RunnerService.csproj b/src/Runner.Service/Windows/RunnerService.csproj index a1034540863..c51f0c3fc9d 100644 --- a/src/Runner.Service/Windows/RunnerService.csproj +++ b/src/Runner.Service/Windows/RunnerService.csproj @@ -2,12 +2,17 @@ Exe - net8.0 + net8.0 + net6.0 NU1701;NU1603;NU1605;CS4014;CA1416 win-x64;win-x86;win-arm64 - + + + + + diff --git a/src/Runner.Worker/Runner.Worker.csproj b/src/Runner.Worker/Runner.Worker.csproj index 53e93c9f1ac..8f93bc3b151 100644 --- a/src/Runner.Worker/Runner.Worker.csproj +++ b/src/Runner.Worker/Runner.Worker.csproj @@ -1,7 +1,8 @@ - net8.0 + net8.0 + net6.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 true @@ -17,12 +18,18 @@ - + + + + + + + GitHub.Runner.Worker.action_yaml.json diff --git a/src/Runner.Worker/RunnerPluginManager.cs b/src/Runner.Worker/RunnerPluginManager.cs index 64427d96cc4..5dcc256b09a 100644 --- a/src/Runner.Worker/RunnerPluginManager.cs +++ b/src/Runner.Worker/RunnerPluginManager.cs @@ -89,23 +89,30 @@ public async Task RunPluginActionAsync(IExecutionContext context, string plugin, string workingDirectory = HostContext.GetDirectory(WellKnownDirectory.Work); ArgUtil.Directory(workingDirectory, nameof(workingDirectory)); - // Runner.PluginHost -#if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - string ext = ".dll"; -#else - string ext = IOUtil.ExeExtension; -#endif - string file = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), $"Runner.PluginHost{ext}"); - ArgUtil.File(file, $"Runner.PluginHost{ext}"); + string file; // Runner.PluginHost's arguments string arguments = $"action \"{plugin}\""; + var binpath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + if(string.IsNullOrWhiteSpace(binpath)) { + file = Environment.ProcessPath; + } else { + // Runner.PluginHost +#if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 + string ext = ".dll"; +#else + string ext = IOUtil.ExeExtension; +#endif + file = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), $"Runner.PluginHost{ext}"); + ArgUtil.File(file, $"Runner.PluginHost{ext}"); + #if !OS_LINUX && !OS_WINDOWS && !OS_OSX && !X64 && !X86 && !ARM && !ARM64 - var dotnet = global::Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); - arguments = $"\"{file}\" {arguments}"; - file = dotnet; + var dotnet = global::Sdk.Utils.DotNetMuxer.MuxerPath ?? WhichUtil.Which("dotnet", true); + arguments = $"\"{file}\" {arguments}"; + file = dotnet; #endif + } // construct plugin context RunnerActionPluginExecutionContext pluginContext = new() { diff --git a/src/Sdk/Sdk.csproj b/src/Sdk/Sdk.csproj index 1480bcc521f..0166ad1632a 100644 --- a/src/Sdk/Sdk.csproj +++ b/src/Sdk/Sdk.csproj @@ -1,10 +1,10 @@ - net8.0 + net8.0 + net6.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64 - true NU1701;NU1603;SYSLIB0050;SYSLIB0051 $(Version) @@ -21,8 +21,6 @@ - - @@ -31,6 +29,16 @@ + + + + + + + + + + $(DefineConstants);HAVE_YAML_DOTNET_FORK