Exemple #1
0
        private RestoreSummaryRequest Create(
            string inputPath,
            RestoreArgs restoreContext)
        {
            var file = new FileInfo(inputPath);

            // Get settings relative to the input file
            var settings = restoreContext.GetSettings(file.DirectoryName);

            var sources = restoreContext.GetEffectiveSources(settings, null);
            var FallbackPackageFolders = restoreContext.GetEffectiveFallbackPackageFolders(settings);

            var globalPath = restoreContext.GetEffectiveGlobalPackagesFolder(file.DirectoryName, settings);

            var sharedCache = _providerCache.GetOrCreate(
                globalPath,
                FallbackPackageFolders,
                sources,
                restoreContext.CacheContext,
                restoreContext.Log);

            var project = JsonPackageSpecReader.GetPackageSpec(file.Directory.Name, file.FullName);

            var request = new RestoreRequest(
                project,
                sharedCache,
                restoreContext.CacheContext,
                restoreContext.Log);

            restoreContext.ApplyStandardProperties(request);

            var summaryRequest = new RestoreSummaryRequest(request, inputPath, SettingsUtility.GetConfigFilePaths(settings), sources);

            return(summaryRequest);
        }
        protected virtual RestoreSummaryRequest Create(
            ExternalProjectReference project,
            MSBuildProjectReferenceProvider msbuildProvider,
            RestoreArgs restoreContext,
            ISettings settingsOverride)
        {
            // Get settings relative to the input file
            var rootPath = Path.GetDirectoryName(project.PackageSpecPath);

            var settings = settingsOverride;

            if (settings == null)
            {
                settings = restoreContext.GetSettings(rootPath);
            }

            var globalPath    = restoreContext.GetEffectiveGlobalPackagesFolder(rootPath, settings);
            var fallbackPaths = restoreContext.GetEffectiveFallbackPackageFolders(settings);

            var sources = restoreContext.GetEffectiveSources(settings);

            var sharedCache = _providerCache.GetOrCreate(
                globalPath,
                fallbackPaths,
                sources,
                restoreContext.CacheContext,
                restoreContext.Log);

            var request = new RestoreRequest(
                project.PackageSpec,
                sharedCache,
                restoreContext.Log,
                disposeProviders: false);

            restoreContext.ApplyStandardProperties(request);

            // Find all external references
            var externalReferences = msbuildProvider.GetReferences(project.MSBuildProjectPath).ToList();

            request.ExternalProjects = externalReferences;

            // Determine if this needs to fall back to an older lock file format
            // Skip this if the arguments override the lock file version
            if (restoreContext.LockFileVersion == null)
            {
                request.LockFileVersion = LockFileUtilities.GetLockFileVersion(externalReferences);
            }

            // The lock file is loaded later since this is an expensive operation

            var summaryRequest = new RestoreSummaryRequest(
                request,
                project.MSBuildProjectPath,
                settings,
                sources);

            return(summaryRequest);
        }
Exemple #3
0
        private RestoreSummaryRequest Create(
            ExternalProjectReference project,
            HashSet <ExternalProjectReference> projectReferenceClosure,
            RestoreArgs restoreContext,
            ISettings settingsOverride)
        {
            // Get settings relative to the input file
            var rootPath = Path.GetDirectoryName(project.PackageSpec.FilePath);

            var settings = settingsOverride;

            if (settings == null)
            {
                settings = restoreContext.GetSettings(rootPath);
            }

            var globalPath    = restoreContext.GetEffectiveGlobalPackagesFolder(rootPath, settings);
            var fallbackPaths = restoreContext.GetEffectiveFallbackPackageFolders(settings);

            var sources = restoreContext.GetEffectiveSources(settings);

            var sharedCache = _providerCache.GetOrCreate(
                globalPath,
                fallbackPaths,
                sources,
                restoreContext.CacheContext,
                restoreContext.Log);

            // Create request
            var request = new RestoreRequest(
                project.PackageSpec,
                sharedCache,
                restoreContext.CacheContext,
                restoreContext.Log);

            // Set properties from the restore metadata
            request.ProjectStyle      = project.PackageSpec?.RestoreMetadata?.ProjectStyle ?? ProjectStyle.Unknown;
            request.RestoreOutputPath = project.PackageSpec?.RestoreMetadata?.OutputPath ?? rootPath;
            var restoreLegacyPackagesDirectory = project.PackageSpec?.RestoreMetadata?.LegacyPackagesDirectory
                                                 ?? DefaultRestoreLegacyPackagesDirectory;

            request.IsLowercasePackagesDirectory = !restoreLegacyPackagesDirectory;

            // Standard properties
            restoreContext.ApplyStandardProperties(request);

            // Add project references
            request.ExternalProjects = projectReferenceClosure.ToList();

            // The lock file is loaded later since this is an expensive operation
            var summaryRequest = new RestoreSummaryRequest(
                request,
                project.MSBuildProjectPath,
                settings,
                sources);

            return(summaryRequest);
        }