public static string From(this AppRuntimeVersion appRuntimeVersion) { switch (appRuntimeVersion) { case AppRuntimeVersion.DotnetCore2_1: return("netcoreapp2.1"); case AppRuntimeVersion.DotnetCore3_1: return("netcoreapp3.1"); case AppRuntimeVersion.DotnetCore5Preview: return(""); default: throw new ArgumentOutOfRangeException("appRuntimeVersion"); } }
public Task PublishApp(string pathToCsproj, string appName, AppRuntimeVersion appRuntime) { _feedbackChannel.SendFeedback($"- - - - Publishing App: {appName} - - - -"); var isRelease = true; // Hardcoded for now. var configuration = isRelease ? "Release" : "Debug"; var framework = appRuntime; var isSelfContained = false; var osRuntime = "linux-x64"; var output = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + $"/dotnetdeploy/{appName}"; var script = $"publish {pathToCsproj} --configuration {configuration} --framework {framework.From()} --self-contained {isSelfContained.ToString().ToLower()} --runtime {osRuntime} --output {output}"; // --verbosity quiet _feedbackChannel.SendFeedback($"dotnet ${script}"); var result = script.Cmd(); _feedbackChannel.SendFeedback(result); _feedbackChannel.SendFeedback($"- - - - Publishing completed for App: {appName} - - - -"); return(Task.CompletedTask); }
public async Task InstallAppRuntimeAsync(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion) { try { await _feedbackChannel.SendFeedback($"- - - - Installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -"); using (var client = _sshClient) { client.Connect(); if (_scriptManager.GetScript(osVersion, appRuntimeVersion, out List <string> scriptLines)) { foreach (var scriptLine in scriptLines) { await _feedbackChannel.SendFeedback($"$ {scriptLine}"); var output = await client.RunCommandAsync(scriptLine); await _feedbackChannel.SendFeedback(output); } await _feedbackChannel.SendFeedback($"- - - - Finished installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -"); } else { await _feedbackChannel.SendFeedback($"{nameof(osVersion)} combined with {nameof(appRuntimeVersion)} is currently not a supported combination."); } } } catch (Exception e) { await _feedbackChannel.SendFeedback($"- - - - Failed installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion}, with error: {e.Message} - - - - "); _logger.LogWarning(e.Message); } }
public bool GetScript(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion, out List <string> scriptLines) { return(ScriptDictionary.TryGetValue(new ScriptKey(osVersion, appRuntimeVersion), out scriptLines)); }
public ScriptKey(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion) { OsVersion = osVersion; AppRuntimeVersion = appRuntimeVersion; }