コード例 #1
0
        private async Task <PowerShellResult> ExecuteScriptAsync(string script)
        {
            consoleLogger.Debug(script);

            var documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var currentUserCurrentHostProfile = Path.Combine(documentsFolder, "WindowsPowerShell\\Microsoft.PowerShell_profile.ps1");

            var environmentReadyScript = $@"
$env:Path = [System.Environment]::GetEnvironmentVariable(""Path"",""Machine"") + "";"" + [System.Environment]::GetEnvironmentVariable(""Path"",""User"")

if ($profile -eq $null -or $profile -eq '') {{
  $global:profile = ""{currentUserCurrentHostProfile}""
}}

{script}";

            powershell.AddScript(environmentReadyScript);

            var output = await powershell.InvokeAsync();

            var result = output.LastOrDefault();

            Clear();

            return(new PowerShellResult
            {
                AsString = result?.ToString() ?? ""
            });
        }
コード例 #2
0
        private async Task ExecuteInternalAsync()
        {
            await systemInitializer.InitializeAsync();

            var manifest = await manifestRepository.LoadAsync();

            consoleLogger.Debug($"Loaded {manifest.Apps.Count} {nameof(manifest.Apps)}");

            await InstallAppsAsync(manifest.Apps);
        }
コード例 #3
0
        public static void SetUpdaterProxy(GitHubUpdater updater, string httpProxy, IConsoleLogger log)
        {
            var httpProxyFromEnv = Environment.GetEnvironmentVariable("OE_HTTP_PROXY");

            if (string.IsNullOrEmpty(httpProxy) && !string.IsNullOrEmpty(httpProxyFromEnv))
            {
                log.Debug($"Using the proxy found in the environment variable OE_HTTP_PROXY: {httpProxyFromEnv.PrettyQuote()}.");
                httpProxy = httpProxyFromEnv;
            }

            httpProxyFromEnv = Environment.GetEnvironmentVariable("http_proxy");

            if (string.IsNullOrEmpty(httpProxy) && !string.IsNullOrEmpty(httpProxyFromEnv))
            {
                log.Debug($"Using the proxy found in the environment variable HTTP_PROXY: {httpProxyFromEnv.PrettyQuote()}.");
                httpProxy = httpProxyFromEnv;
            }

            if (!string.IsNullOrEmpty(httpProxy) && httpProxy.ParseWebProxy(out var host, out var port, out var user, out var password))
            {
                log.Debug($"Using http proxy: {httpProxy.PrettyQuote()}.");
                updater.UseProxy($"{host}:{port}", user, password);
            }
        }
コード例 #4
0
 private async Task <TResponse> LogAndGo(ILogged request, RequestHandlerDelegate <TResponse> next)
 {
     _log.Debug(request.LogMessage);
     return(await next());
 }