public NuGetPluginSolution(DirectoryPath pluginDirPath,
                                   DirectoryPath pluginHomeDirPath,
                                   DirectoryPath packageDirPath,
                                   NuGetInstalledPluginRepository <TMeta> pluginRepo,
                                   SourceRepositoryProvider sourceRepositories,
                                   ISettings settings,
                                   NuGetFramework currentFramework)
        {
            SolutionDirectory   = pluginDirPath.Collapse().FullPath;
            NuGetProjectContext = new NuGetProjectContext(settings);

            _packageDirPath     = packageDirPath;
            _pluginHomeDirPath  = pluginHomeDirPath;
            _pluginRepo         = pluginRepo;
            _sourceRepositories = sourceRepositories;
            _settings           = settings;
            _currentFramework   = currentFramework;

            _projectMap = _pluginRepo.Plugins.Select(
                p => new NuGetPluginProject <TMeta>(
                    CreatePackageManager,
                    _currentFramework,
                    _packageDirPath,
                    _pluginHomeDirPath,
                    p,
                    true)
                ).ToDictionary(k => k.Plugin.Id);
        }
Esempio n. 2
0
        /// <summary>Instantiates a new package manager</summary>
        /// <param name="pluginDirPath"></param>
        /// <param name="pluginHomeDirPath"></param>
        /// <param name="packageDirPath"></param>
        /// <param name="configFilePath"></param>
        /// <param name="providerCreator"></param>
        /// <returns></returns>
        public static async Task <PluginPackageManager <TMeta> > Create(
            DirectoryPath pluginDirPath,
            DirectoryPath pluginHomeDirPath,
            DirectoryPath packageDirPath,
            FilePath configFilePath,
            Func <ISettings, NuGet.SourceRepositoryProvider> providerCreator = null)
        {
            pluginDirPath  = pluginDirPath.Collapse();
            packageDirPath = packageDirPath.Collapse();

            if (pluginDirPath.EnsureExists() == false)
            {
                throw new ArgumentException($"Root path {pluginDirPath.FullPath} doesn't exist and couldn't be created.");
            }

            if (packageDirPath.EnsureExists() == false)
            {
                throw new ArgumentException($"Package path {packageDirPath.FullPath} doesn't exist and couldn't be created.");
            }

            if (configFilePath.Directory.Exists() == false)
            {
                throw new ArgumentException($"Config file's directory {configFilePath.Directory.FullPath} doesn't exist and couldn't be created.");
            }

            var packageCache = await NuGetInstalledPluginRepository <TMeta> .LoadAsync(configFilePath, pluginHomeDirPath);

            return(new PluginPackageManager <TMeta>(
                       pluginDirPath,
                       pluginHomeDirPath,
                       packageDirPath,
                       packageCache,
                       providerCreator));
        }
Esempio n. 3
0
        public IDirectory GetDirectory(DirectoryPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(GetFileProvider(path).GetDirectory(path.Collapse()));
        }
Esempio n. 4
0
            public void ShouldCollapse(string fullPath, string expected)
            {
                // Given
                DirectoryPath directoryPath = new DirectoryPath(fullPath);

                // When
                DirectoryPath path = directoryPath.Collapse();

                // Then
                Assert.AreEqual(expected, path.FullPath);
            }
Esempio n. 5
0
            public void CollapseRetainsProvider()
            {
                // Given
                DirectoryPath directoryPath = new DirectoryPath(new Uri("foo:///"), "/a/b/../c");

                // When
                DirectoryPath path = directoryPath.Collapse();

                // Then
                Assert.AreEqual("/a/c", path.FullPath);
                Assert.AreEqual(new Uri("foo:///"), path.FileProvider);
            }
Esempio n. 6
0
        public LocalDirectory(DirectoryPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (path.IsRelative)
            {
                throw new ArgumentException("Path must be absolute", nameof(path));
            }

            _path      = path.Collapse();
            _directory = new DirectoryInfo(_path.FullPath);
        }
 public ActionFileSystemWatcher(DirectoryPath outputDirectory, IEnumerable <DirectoryPath> inputDirectories, bool includeSubdirectories, string filter, Action <string> callback)
 {
     foreach (string inputDirectory in inputDirectories.Select(x => x.Collapse().FullPath).Where(Directory.Exists))
     {
         FileSystemWatcher watcher = new FileSystemWatcher
         {
             Path = inputDirectory,
             IncludeSubdirectories = includeSubdirectories,
             Filter = filter,
             EnableRaisingEvents = true
         };
         watcher.Changed += OnChanged;
         watcher.Created += OnChanged;
         _watchers.Add(watcher);
     }
     _outputPath = outputDirectory.Collapse().FullPath;
     _callback   = callback;
 }
        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
                );
        }
Esempio n. 9
0
 public TestDirectory(TestFileProvider fileProvider, DirectoryPath path)
 {
     _fileProvider = fileProvider;
     _path         = path.Collapse();
 }
Esempio n. 10
0
 public IDirectory GetDirectory(DirectoryPath path) =>
 new TestDirectory(this, path.Collapse().FullPath);