public async Task <ProcessRunner.ProcessResult> RestoreAsync(ILogger logger, CancellationToken cancellationToken) { ThrowOnDisposed(); if (!_isSaved) { await this.SaveAsync(logger, cancellationToken).ConfigureAwait(false); } var restoreParams = "restore --ignore-failed-sources" + (string.IsNullOrWhiteSpace(this.RuntimeIdentifier) ? "" : (" -r " + this.RuntimeIdentifier)); // Restore no-dependencies first to workaround NuGet issue https://github.com/NuGet/Home/issues/4979 await ProcessRunner.TryRunAsync("dotnet", restoreParams + " --no-dependencies", this.DirectoryPath, logger, cancellationToken).ConfigureAwait(false); var result = await ProcessRunner.TryRunAsync("dotnet", restoreParams, this.DirectoryPath, logger, cancellationToken).ConfigureAwait(false); return(result); }
public static async Task <string> GetSdkVersionAsync(string workingDirectory, ILogger logger, CancellationToken cancellationToken) { if (s_sdkVersion == null) { using (var safeLogger = await SafeLogger.WriteStartOperationAsync(logger, "Resolving dotnet sdk version ...").ConfigureAwait(false)) { var procResult = await ProcessRunner.TryRunAsync("dotnet", "--version", workingDirectory, logger, cancellationToken).ConfigureAwait(false); if (procResult.ExitCode == 0) { s_sdkVersion = procResult.OutputText.Trim(); } await safeLogger.WriteMessageAsync($"dotnet sdk version:{s_sdkVersion}", logToUI : false).ConfigureAwait(false); } } return(s_sdkVersion); }