public async Task <bool> NominateProjectAsync(string projectUniqueName, CancellationToken token) { Assumes.NotNullOrEmpty(projectUniqueName); if (!_projectSystemCache.TryGetProjectNames(projectUniqueName, out ProjectNames projectNames)) { IVsSolution2 vsSolution2 = await _vsSolution2.GetValueAsync(token); projectNames = await ProjectNames.FromIVsSolution2(projectUniqueName, vsSolution2, token); } var dgSpec = new DependencyGraphSpec(); var packageSpec = new PackageSpec() { Name = projectUniqueName }; dgSpec.AddProject(packageSpec); dgSpec.AddRestore(packageSpec.Name); _projectSystemCache.AddProjectRestoreInfo(projectNames, dgSpec, new List <IAssetsLogMessage>()); // returned task completes when scheduled restore operation completes. var restoreTask = _restoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.OnUpdate(), token); return(await restoreTask); }
public Task <bool> NominateProjectAsync(string projectUniqueName, CancellationToken token) { Assumes.NotNullOrEmpty(projectUniqueName); // returned task completes when scheduled restore operation completes. var restoreTask = _restoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.OnUpdate(), token); return(restoreTask); }
private async Task <bool> RestoreProjectAsync(CancellationToken token) { await ShowProgressUIAsync(); OperationId = Guid.NewGuid(); return(await _solutionRestoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.ByUserCommand(ExplicitRestoreReason.MissingPackagesBanner), token)); }
private async Task <bool> RestoreProjectAsync(CancellationToken token) { await ShowProgressUIAsync(); OperationId = Guid.NewGuid(); return(await _solutionRestoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.ByMenu(), token)); }
public Task <bool> NominateProjectAsync(string projectUniqueName, IVsProjectRestoreInfo projectRestoreInfo, CancellationToken token) { if (string.IsNullOrEmpty(projectUniqueName)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(projectUniqueName)); } if (projectRestoreInfo == null) { throw new ArgumentNullException(nameof(projectRestoreInfo)); } if (projectRestoreInfo.TargetFrameworks == null) { throw new InvalidOperationException("TargetFrameworks cannot be null."); } try { _logger.LogInformation( $"The nominate API is called for '{projectUniqueName}'."); var projectNames = ProjectNames.FromFullProjectPath(projectUniqueName); var dgSpec = ToDependencyGraphSpec(projectNames, projectRestoreInfo); #if DEBUG DumpProjectRestoreInfo(projectUniqueName, dgSpec); #endif _projectSystemCache.AddProjectRestoreInfo(projectNames, dgSpec); // returned task completes when scheduled restore operation completes. var restoreTask = _restoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.OnUpdate(), token); return(restoreTask); } catch (Exception e) when(e is InvalidOperationException || e is ArgumentException || e is FormatException) { _logger.LogError(e.ToString()); return(Task.FromResult(false)); } catch (Exception e) { _logger.LogError(e.ToString()); throw; } }
public static RestoreTask Start(ISolutionRestoreWorker worker, bool forceRestore) { var cts = new CancellationTokenSource(); var task = worker .JoinableTaskFactory .RunAsync(() => worker.ScheduleRestoreAsync( SolutionRestoreRequest.OnBuild(forceRestore), cts.Token)) .Task; return(new RestoreTask { _cts = cts, _task = task }); }