Esempio n. 1
0
            internal async Task OnRestoreInfoChangedAsync(IProjectVersionedValue <PackageRestoreUnconfiguredInput> e)
            {
                PackageRestoreUnconfiguredInput update      = e.Value;
                IVsProjectRestoreInfo2?         restoreInfo = e.Value.RestoreInfo;

                // Restore service always does work regardless of whether the value we pass them to actually
                // contains changes, only nominate if there are any.
                if (RestoreComparer.RestoreInfos.Equals(_latestValue, restoreInfo))
                {
                    return;
                }

                // No configurations - likely during project close
                if (restoreInfo == null)
                {
                    return;
                }

                _latestValue = restoreInfo;

                JoinableTask joinableTask = JoinableFactory.RunAsync(() =>
                {
                    return(NominateProjectRestoreAsync(restoreInfo, _projectAsynchronousTasksService.UnloadCancellationToken));
                });

                _projectAsynchronousTasksService.RegisterAsyncTask(joinableTask,
                                                                   ProjectCriticalOperation.Build | ProjectCriticalOperation.Unload | ProjectCriticalOperation.Rename,
                                                                   registerFaultHandler: true);

                // Prevent overlap until Restore completes
                await joinableTask;
            }
Esempio n. 2
0
        private async Task <bool> RestoreCoreAsync(PackageRestoreUnconfiguredInput value)
        {
            ProjectRestoreInfo?restoreInfo = value.RestoreInfo;
            bool success = false;

            Assumes.NotNull(restoreInfo);

            try
            {
                // Restore service always does work regardless of whether the value we pass
                // them to actually contains changes, only nominate if there are any.
                byte[] hash = RestoreHasher.CalculateHash(restoreInfo);

                if (_latestHash != null && hash.AsSpan().SequenceEqual(_latestHash))
                {
                    SaveNominatedConfiguredVersions(value.ConfiguredInputs);
                    return(true);
                }

                _latestHash = hash;

                _restoreStarted = true;
                JoinableTask <bool> joinableTask = JoinableFactory.RunAsync(() =>
                {
                    return(NominateForRestoreAsync(restoreInfo, _projectAsynchronousTasksService.UnloadCancellationToken));
                });

                SaveNominatedConfiguredVersions(value.ConfiguredInputs);

                _projectAsynchronousTasksService.RegisterAsyncTask(joinableTask,
                                                                   ProjectCriticalOperation.Build | ProjectCriticalOperation.Unload | ProjectCriticalOperation.Rename,
                                                                   registerFaultHandler: true);

                // Prevent overlap until Restore completes
                success = await joinableTask;

                lock (SyncObject)
                {
                    _restoreStarted = false;
                }

                HintProjectDependentFile(restoreInfo);
            }
            finally
            {
                _restoreStarted = false;
            }

            return(success);
        }