private async Task <string> GetBaseDirectoryAsync(BootstrapStartOptions startOptions) { string baseDir; if (!string.IsNullOrWhiteSpace(startOptions.BaseDir) && Directory.Exists(startOptions.BaseDir)) { _logger.Write($"Using base directory '{startOptions.BaseDir}' from start options", _Prefix); baseDir = startOptions.BaseDir; } else { if (IsBetterRunOnLocalTempStorage() && await IsCurrentDirectoryClonableAsync()) { string clonedDirectory = await CloneDirectoryAsync(); baseDir = clonedDirectory; } else { baseDir = VcsPathHelper.FindVcsRootPath(); } } return(baseDir); }
private async Task <BootstrapStartOptions> StartWithDebuggerAsync([NotNull] string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } string baseDir = VcsPathHelper.FindVcsRootPath(AppDomain.CurrentDomain.BaseDirectory); var tempDirectory = new DirectoryInfo(Path.Combine( Path.GetTempPath(), $"{DefaultPaths.TempPathPrefix}_Boot_Debug", DateTime.Now.ToString("yyyyMMddHHmmssfff"))); tempDirectory.EnsureExists(); WriteDebug($"Using temp directory '{tempDirectory}'"); await DirectoryCopy.CopyAsync(baseDir, tempDirectory.FullName); Environment.SetEnvironmentVariable(WellKnownVariables.BranchNameVersionOverrideEnabled, "true"); Environment.SetEnvironmentVariable(WellKnownVariables.VariableOverrideEnabled, "true"); var bootstrapStartOptions = new BootstrapStartOptions( tempDirectory.FullName, true, "refs/heads/develop/12.34.56"); WriteDebug("Starting with debugger attached"); return(bootstrapStartOptions); }
public async Task <ExitCode> StartAsync(BootstrapStartOptions startOptions) { _startOptions = startOptions ?? new BootstrapStartOptions(); SetEnvironmentVariables(); var stopwatch = new Stopwatch(); stopwatch.Start(); ExitCode exitCode; try { exitCode = await TryStartAsync(); stopwatch.Stop(); } catch (AggregateException ex) { stopwatch.Stop(); exitCode = ExitCode.Failure; _logger.WriteError(ex.ToString(), _Prefix); foreach (Exception innerEx in ex.InnerExceptions) { _logger.WriteError(innerEx.ToString(), _Prefix); } } catch (Exception ex) { stopwatch.Stop(); exitCode = ExitCode.Failure; _logger.WriteError(ex.ToString(), _Prefix); } ParseResult <int> exitDelayInMilliseconds = Environment.GetEnvironmentVariable(WellKnownVariables.BootstrapperExitDelayInMilliseconds) .TryParseInt32(0); if (exitDelayInMilliseconds > 0) { _logger.Write( $"Delaying bootstrapper exit with {exitDelayInMilliseconds} milliseconds as specified in '{WellKnownVariables.BootstrapperExitDelayInMilliseconds}'", _Prefix); await Task.Delay(TimeSpan.FromMilliseconds(exitDelayInMilliseconds)); } _logger.Write( $"Arbor.X.Bootstrapper total inclusive Arbor.X.Build elapsed time in seconds: {stopwatch.Elapsed.TotalSeconds.ToString("F")}", _Prefix); return(exitCode); }
public async Task <ExitCode> StartAsync(string[] args) { BootstrapStartOptions startOptions; if (Debugger.IsAttached) { startOptions = await StartWithDebuggerAsync(args); } else { startOptions = BootstrapStartOptions.Parse(args); } ExitCode exitCode = await StartAsync(startOptions); _logger.Write($"Bootstrapper exit code: {exitCode}"); if (_failed) { exitCode = ExitCode.Failure; } return(exitCode); }