Example #1
0
        /// <summary>
        /// Create a restore context.
        /// </summary>
        private static RestoreArgs GetRestoreContext(
            DependencyGraphCacheContext context,
            RestoreCommandProvidersCache providerCache,
            SourceCacheContext sourceCacheContext,
            IEnumerable <SourceRepository> sources,
            DependencyGraphSpec dgFile,
            bool forceRestore)
        {
            var caching = new CachingSourceProvider(new PackageSourceProvider(context.Settings));

            foreach (var source in sources)
            {
                caching.AddSourceRepository(source);
            }

            var dgProvider = new DependencyGraphSpecRequestProvider(providerCache, dgFile);

            var restoreContext = new RestoreArgs()
            {
                CacheContext = sourceCacheContext,
                PreLoadedRequestProviders = new List <IPreLoadedRestoreRequestProvider>()
                {
                    dgProvider
                },
                Log                   = context.Logger,
                AllowNoOp             = !forceRestore,
                CachingSourceProvider = caching
            };

            return(restoreContext);
        }
        /// <summary>
        /// Create a restore args.
        /// </summary>
        private static RestoreArgs GetRestoreArgs(
            DependencyGraphCacheContext context,
            RestoreCommandProvidersCache providerCache,
            SourceCacheContext sourceCacheContext,
            IEnumerable <SourceRepository> sources,
            DependencyGraphSpec dgFile,
            Guid parentId,
            bool forceRestore,
            bool isRestoreOriginalAction,
            bool restoreForceEvaluate,
            IReadOnlyList <IAssetsLogMessage> additionalMessasges,
            IRestoreProgressReporter progressReporter)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var caching = new CachingSourceProvider(new PackageSourceProvider(context.Settings, enablePackageSourcesChangedEvent: false));
#pragma warning restore CS0618 // Type or member is obsolete
            foreach (var source in sources)
            {
                caching.AddSourceRepository(source);
            }

            var dgProvider = new DependencyGraphSpecRequestProvider(providerCache, dgFile);

            var restoreContext = new RestoreArgs()
            {
                CacheContext = sourceCacheContext,
                PreLoadedRequestProviders = new List <IPreLoadedRestoreRequestProvider>()
                {
                    dgProvider
                },
                Log                     = context.Logger,
                AllowNoOp               = !forceRestore,
                CachingSourceProvider   = caching,
                ParentId                = parentId,
                IsRestoreOriginalAction = isRestoreOriginalAction,
                RestoreForceEvaluate    = restoreForceEvaluate,
                AdditionalMessages      = additionalMessasges,
                ProgressReporter        = progressReporter,
            };

            return(restoreContext);
        }