示例#1
0
        private PluginPackageManager(DirectoryPath pluginDirPath,
                                     DirectoryPath pluginHomeDirPath,
                                     DirectoryPath packageDirPath,
                                     NuGetInstalledPluginRepository <TMeta> packageCache,
                                     Func <ISettings, NuGet.SourceRepositoryProvider> providerCreator =
                                     null)
        {
            var settings = Settings.LoadDefaultSettings(packageDirPath.FullPath, null, new NuGetMachineWideSettings());

            _currentFramework  = GetCurrentFramework();
            SourceRepositories = providerCreator?.Invoke(settings) ?? new NuGet.SourceRepositoryProvider(settings);
            PluginRepo         = packageCache;

            var localRepo = SourceRepositories.CreateRepository(
                new PackageSource(packageDirPath.FullPath, "Local", true),
                FeedType.FileSystemPackagesConfig);

            Solution = new NuGetPluginSolution <TMeta>(
                pluginDirPath, pluginHomeDirPath, packageDirPath,
                PluginRepo,
                SourceRepositories,
                settings,
                _currentFramework
                );
        }
        internal PluginPackageManager(DirectoryPath pluginDirPath,
                                      DirectoryPath pluginHomeDirPath,
                                      DirectoryPath packageDirPath,
                                      FilePath configFilePath,
                                      Func <ISettings, SourceRepositoryProvider> providerCreator = null)
        {
            pluginDirPath  = pluginDirPath.Collapse();
            packageDirPath = packageDirPath.Collapse();

            if (pluginDirPath.Exists() == false)
            {
                throw new ArgumentException($"Root path {pluginDirPath.FullPath} doesn't exist.");
            }

            if (packageDirPath.Exists() == false)
            {
                throw new ArgumentException($"Package path {packageDirPath.FullPath} doesn't exist.");
            }

            if (configFilePath.Root.Exists() == false)
            {
                throw new ArgumentException($"Config's root directory {configFilePath.Root.FullPath} doesn't exist.");
            }

            var packageCacheTask = NuGetInstalledPluginRepository <TMeta> .LoadAsync(configFilePath);

            var settings = Settings.LoadDefaultSettings(packageDirPath.FullPath, null, new MachineWideSettings());

            _currentFramework   = GetCurrentFramework();
            _sourceRepositories = providerCreator?.Invoke(settings) ?? new SourceRepositoryProvider(settings);
            _pluginRepo         = packageCacheTask.Result;
            _solution           = new NuGetPluginSolution <TMeta>(
                pluginDirPath, pluginHomeDirPath, packageDirPath,
                _pluginRepo,
                _sourceRepositories,
                settings,
                _currentFramework
                );
        }