public void ExistIsNotCached() { Directory.CreateDirectory("dir1"); var dir = new DirectoryPath("dir1"); Assert.True(dir.Exists()); Directory.Delete("dir1"); Assert.False(dir.Exists()); }
public static void ThrowIfNotExists(this DirectoryPath path, string errMsg) { if (!path.Exists()) { throw new InvalidOperationException(errMsg); } }
public async Task UninstallPluginAsync( INuGetProjectContext projectContext, bool removeDependencies = true, bool forceRemove = false, CancellationToken cancellationToken = default) { var uninstallContext = new UninstallationContext(removeDependencies, forceRemove); await CreatePackageManager().UninstallPackageAsync( this, Plugin.Id, uninstallContext, projectContext, cancellationToken); if (_pluginHomeDirPath.Exists()) { _pluginHomeDirPath.Delete(); } }
protected FileStream OpenConf(DirectoryPath dirPath, Type confType, FileAccess fileAccess) { if (!dirPath.Exists()) return null; var filePath = GetConfigFilePath(dirPath, confType); return File.Open(filePath.FullPath, fileAccess == FileAccess.Read ? FileMode.OpenOrCreate : FileMode.Create, fileAccess); }
public void ExistIsFalseIfFileExists() { try { File.WriteAllText("file1", "test"); var dir = new DirectoryPath("file"); Assert.False(dir.Exists()); } finally { File.Delete("file1"); } }
public void ExistIsTrueIfDirectoryExists() { try { Directory.CreateDirectory("dir"); var dir = new DirectoryPath("dir"); Assert.True(dir.Exists()); } finally { Directory.Delete("dir"); } }
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 ); }
public void ExistIsFalseIfDirectoryDoesNotExists() { var dir = new DirectoryPath("dir0"); Assert.False(dir.Exists()); }