Example #1
0
        //returns the lock file, if it changed
        async Task <string> RestorePackagesInternal(
            BuildIntegratedNuGetProject project,
            CancellationToken cancellationToken)
        {
            var now = DateTime.UtcNow;
            Action <SourceCacheContext> cacheContextModifier = c => c.MaxAge = now;

            var spec = await MonoDevelopDependencyGraphRestoreUtility.GetSolutionRestoreSpec(solutionManager, project, context, cancellationToken);

            context.AddToCache(spec);

            RestoreResult restoreResult = await DependencyGraphRestoreUtility.RestoreProjectAsync(
                solutionManager,
                project,
                context,
                new RestoreCommandProvidersCache(),
                cacheContextModifier,
                sourceRepositories,
                Guid.NewGuid(),
                context.Logger,
                cancellationToken);

            if (restoreResult.Success)
            {
                if (!object.Equals(restoreResult.LockFile, restoreResult.PreviousLockFile))
                {
                    return(restoreResult.LockFilePath);
                }
            }
            else
            {
                ReportRestoreError(restoreResult);
            }
            return(null);
        }
Example #2
0
        public async Task RestorePackages(
            IEnumerable <BuildIntegratedNuGetProject> projects,
            CancellationToken cancellationToken)
        {
            var spec = await MonoDevelopDependencyGraphRestoreUtility.GetSolutionRestoreSpec(solutionManager, projects, context, cancellationToken);

            var now = DateTime.UtcNow;
            Action <SourceCacheContext> cacheContextModifier = c => c.MaxAge = now;
            bool forceRestore            = false;
            bool isRestoreOriginalAction = true;

            var restoreSummaries = await DependencyGraphRestoreUtility.RestoreAsync(
                solutionManager,
                spec,
                context,
                new RestoreCommandProvidersCache(),
                cacheContextModifier,
                sourceRepositories,
                Guid.NewGuid(),
                forceRestore,
                isRestoreOriginalAction,
                context.Logger,
                cancellationToken);

            bool restoreFailed    = false;
            int  noOpRestoreCount = 0;

            foreach (RestoreSummary restoreSummary in restoreSummaries)
            {
                if (restoreSummary.Success && restoreSummary.NoOpRestore)
                {
                    noOpRestoreCount++;
                }
                else if (!restoreSummary.Success)
                {
                    restoreFailed = true;
                }
            }

            if (noOpRestoreCount == projects.Count())
            {
                // Nothing to do.
                return;
            }

            if (restoreFailed)
            {
                logger.LogInformation(string.Empty);
                logger.LogSavedErrors();
                throw new ApplicationException(GettextCatalog.GetString("Restore failed."));
            }

            await OnProjectsRestored(projects);
        }