public IEnumerable <IFile> Install(PackageDefinition package, DirectoryPath root) { var result = new List <FilePath>(); var paths = new FilePathCollection(PathComparer.Default); // InstallPackage the package. var packagePath = InstallPackage(package, root); var packageDirectory = _fileSystem.GetDirectory(packagePath); if (package.Filters != null && package.Filters.Count > 0) { // Get all files matching the filters. foreach (var filter in package.Filters) { var pattern = string.Concat(packagePath.FullPath, "/", filter.TrimStart('/', '\\')); paths.Add(_globber.GetFiles(pattern)); } } else { // Do a recursive search in the package directory. paths.Add(packageDirectory. GetFiles("*", SearchScope.Recursive) .Select(file => file.Path)); } if (paths.Count > 0) { result.AddRange(paths); } return(result.Select(path => _fileSystem.GetFile(path))); }
private IEnumerable <IFile> GetFiles(DirectoryPath path, PackageReference package, string[] patterns = null) { var collection = new FilePathCollection(new PathComparer(_environment)); // Get default files (exe and dll). patterns = patterns ?? new[] { path.FullPath + "/**/*.exe", path.FullPath + "/**/*.dll" }; foreach (var pattern in patterns) { collection.Add(_globber.GetFiles(pattern)); } // Include files. if (package.Parameters.ContainsKey("include")) { foreach (var include in package.Parameters["include"]) { var includePath = string.Concat(path.FullPath, "/", include.TrimStart('/')); collection.Add(_globber.GetFiles(includePath)); } } // Exclude files. if (package.Parameters.ContainsKey("exclude")) { foreach (var exclude in package.Parameters["exclude"]) { var excludePath = string.Concat(path.FullPath, "/", exclude.TrimStart('/')); collection.Remove(_globber.GetFiles(excludePath)); } } // Return the files. return(collection.Select(p => _fileSystem.GetFile(p)).ToArray()); }
public IEnumerable<IFile> Install(PackageDefinition package, DirectoryPath root) { var result = new List<FilePath>(); var paths = new FilePathCollection(PathComparer.Default); // InstallPackage the package. var packagePath = InstallPackage(package, root); var packageDirectory = _fileSystem.GetDirectory(packagePath); if (package.Filters != null && package.Filters.Count > 0) { // Get all files matching the filters. foreach (var filter in package.Filters) { var pattern = string.Concat(packagePath.FullPath, "/", filter.TrimStart('/', '\\')); paths.Add(_globber.GetFiles(pattern)); } } else { // Do a recursive search in the package directory. paths.Add(packageDirectory. GetFiles("*", SearchScope.Recursive) .Select(file => file.Path)); } if (paths.Count > 0) { result.AddRange(paths); } return result.Select(path => _fileSystem.GetFile(path)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path(bool caseSensitive, int expectedCount) { // Given var collection = new FilePathCollection(new PathComparer(caseSensitive)); collection.Add(new FilePath("A.TXT")); // When collection.Add(new FilePath("a.txt")); // Then Assert.Equal(expectedCount, collection.Count); }
public void Should_Add_Path_If_Not_Already_Present() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add(new FilePath("B.txt")); // When collection.Add(new FilePath("A.txt")); // Then Assert.Equal(2, collection.Count); }
public void Should_Add_Path_If_Not_Already_Present() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add(new FilePath("B.txt")); // When collection.Add(new FilePath("A.txt")); // Then Assert.Equal(2, collection.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path(bool caseSensitive, int expectedCount) { // Given var collection = new FilePathCollection(new PathComparer(caseSensitive)); collection.Add(new FilePath("A.TXT")); // When collection.Add(new FilePath("a.txt")); // Then Assert.Equal(expectedCount, collection.Count); }
public void Should_Return_New_Collection() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add("A.txt"); collection.Add("B.txt"); // When var result = collection - new FilePath("A.txt"); // Then Assert.False(ReferenceEquals(result, collection)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var collection = new FilePathCollection(new PathComparer(caseSensitive)); collection.Add("A.txt"); collection.Add("B.txt"); collection.Add("C.txt"); // When var result = collection - new[] { new FilePath("b.txt"), new FilePath("c.txt") }; // Then Assert.Equal(expectedCount, result.Count); }
public static FilePathCollection GetFilesByPatterns(this ICakeContext context, DirectoryPath root, string[] includePatterns, string[] excludePatterns) { if (excludePatterns.Length == 0) { return(GetFilesByPatterns(context, includePatterns)); } var excludeFiles = context.GetFiles(root.CombineWithFilePath(excludePatterns[0].TrimStart('/')).ToString()); for (var i = 1; i < excludePatterns.Length; i++) { excludeFiles.Add(context.GetFiles(root.CombineWithFilePath(excludePatterns[i].TrimStart('/')).ToString())); } var excludePaths = excludeFiles.Select(e => e.FullPath); var res = new FilePathCollection(); for (var i = 0; i < includePatterns.Length; i++) { var incl = context.GetFiles(root.CombineWithFilePath(includePatterns[i].TrimStart('/')).ToString()); var crt = res.Select(ii => ii.FullPath); foreach (var include in incl) { if (!excludeFiles.Contains(include.FullPath) && !crt.Contains(include.FullPath)) { res.Add(include); } } } return(res); }
public static FilePathCollection GetFilesByPatterns( this ICakeContext context, string root, string[] includePatterns) { root = root.EnsureEndsWith("/"); var res = new FilePathCollection(); for (var i = 0; i < includePatterns.Length; i++) { var incl = context.GetFiles( root + includePatterns[i] .TrimStart('/')); var crt = res.Select(ii => ii.FullPath); foreach (var include in incl) { if (!crt.Contains(include.FullPath)) { res.Add(include); } } } return(res); }
private FilePathCollection GetDirectoryFiles( DirectoryPath directoryPath, IEnumerable <GlobPattern> pattern) { var directory = new Directory(directoryPath); if (!directory.Exists) { const string format = "Directory '{0}' does not exist."; var message = string.Format(CultureInfo.InvariantCulture, format, directoryPath.FullPath); throw new CakeException(message); } var filePathCollection = new FilePathCollection(); var fullGlobs = pattern.Select(x => directoryPath + x.Pattern).ToArray(); foreach (var glob in fullGlobs) { foreach (var file in _context.GetFiles(glob)) { filePathCollection.Add(file); } } return(filePathCollection); }
public static void SignCli(Context context) { FilePath file = context.PackageDir.CombineWithFilePath("VGAudioCli.zip"); DirectoryPath extracted = context.PackageDir.Combine(file.GetFilenameWithoutExtension().ToString()); context.DeleteDirectory(extracted, false); context.Unzip(file, extracted); FilePathCollection toSign = context.GetFiles($"{extracted}/**/VGAudio*.exe"); toSign.Add(context.GetFiles($"{extracted}/**/VGAudio*.dll")); toSign.Add(context.PackageDir.CombineWithFilePath("VGAudioCli.exe")); toSign.Add(context.PackageDir.CombineWithFilePath("VGAudioTools.exe")); SignFiles(context, toSign.Where(context.FileExists), context.ReleaseCertThumbprint); context.Zip(extracted, context.PackageDir.CombineWithFilePath(file.GetFilename())); context.DeleteDirectory(extracted, false); }
public IEnumerable <IFile> Install(CompilerConfiguration options, bool installAddins) { var result = new List <FilePath>(); foreach (var package in options.Packages) { if (!package.IsCore && !installAddins) { continue; } var paths = new FilePathCollection(PathComparer.Default); // Install the package. var packagePath = Install(package); var packageDirectory = _fileSystem.GetDirectory(packagePath); if (package.Filters != null && package.Filters.Count > 0) { // Get all files matching the filters. foreach (var filter in package.Filters) { var pattern = string.Concat(packagePath.FullPath, "/", filter.TrimStart('/', '\\')); paths.Add(_globber.GetFiles(pattern)); } } else { // Do a recursive search in the package directory. paths.Add(packageDirectory. GetFiles("*", SearchScope.Recursive) .Select(file => file.Path)); } if (paths.Count > 0) { result.AddRange(paths); } } return(result.Select(path => _fileSystem.GetFile(path))); }
public void Should_Add_Paths_That_Are_Not_Present() { // Given var collection = new FilePathCollection(new FilePath[] { "A.txt", "B.txt" }, new PathComparer(false)); // When collection.Add(new FilePath[] { "A.txt", "B.txt", "C.txt" }); // Then collection.Count.ShouldBe(3); }
public void Should_Add_Path_If_Not_Already_Present() { // Given var collection = new FilePathCollection(new FilePath[] { "A.txt" }, new PathComparer(false)); // When collection.Add(new FilePath("B.txt")); // Then collection.Count.ShouldBe(2); }
public void Should_Add_Paths_That_Are_Not_Present() { // Given var collection = new FilePathCollection(new FilePath[] { "A.TXT", "B.TXT" }, new PathComparer(false)); // When collection.Add(new FilePath[] { "A.TXT", "B.TXT", "C.TXT" }); // Then Assert.Equal(3, collection.Count); }
public void Should_Add_Paths_That_Are_Not_Present() { // Given var collection = new FilePathCollection(new FilePath[] { "A.TXT", "B.TXT" }, new PathComparer(false)); // When collection.Add(new FilePath[] { "A.TXT", "B.TXT", "C.TXT" }); // Then Assert.Equal(3, collection.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Paths(bool caseSensitive, int expectedCount) { // Given var collection = new FilePathCollection(new FilePath[] { "A.TXT", "B.TXT" }, new PathComparer(caseSensitive)); // When collection.Add(new FilePath[] { "a.txt", "b.txt", "c.txt" }); // Then collection.Count.ShouldBe(expectedCount); }
public void Should_Throw_If_Paths_Is_Null() { // Given var collection = new FilePathCollection(); // When var result = Record.Exception(() => collection.Add((IEnumerable <FilePath>)null)); // Then AssertEx.IsArgumentNullException(result, "paths"); }
public void Should_Throw_If_Paths_Is_Null() { // Given var collection = new FilePathCollection(); // When var result = Record.Exception(() => collection.Add((IEnumerable <FilePath>)null)); // Then result.ShouldBeOfType <ArgumentNullException>() .And().ParamName.ShouldBe("paths"); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add("B.txt"); // When var result = collection + new FilePath("A.txt"); // Then Assert.Equal(2, result.Count); }
public override void Run(Context context) { RunCoreMsBuild(context, "BuildDotnet", "PublishDotnet"); if (context.RunNetFramework) { BuildTasks.IlRepackCli(context); } context.Zip(context.CliPackageDir, context.PackageDir.CombineWithFilePath("VGAudioCli.zip")); context.DeleteDirectory(context.CliPackageDir, false); if (context.BuildSystem().IsRunningOnAppVeyor) { FilePathCollection uploadFiles = context.GetFiles($"{context.PackageDir}/*.nupkg"); uploadFiles.Add(context.GetFiles($"{context.PackageDir}/*.exe")); uploadFiles.Add(context.GetFiles($"{context.PackageDir}/*.zip")); foreach (FilePath file in uploadFiles) { context.AppVeyor().UploadArtifact(file); } } }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var collection = new FilePathCollection(new PathComparer(caseSensitive)); collection.Add("A.txt"); collection.Add("B.txt"); collection.Add("C.txt"); // When var result = collection - new[] { new FilePath("b.txt"), new FilePath("c.txt") }; // Then Assert.Equal(expectedCount, result.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add("B.txt"); // When var result = collection + new FilePath("A.txt"); // Then Assert.Equal(2, result.Count); }
public void Should_Return_New_Collection() { // Given var collection = new FilePathCollection(new PathComparer(false)); collection.Add("A.txt"); collection.Add("B.txt"); collection.Add("C.txt"); // When var result = collection - new[] { new FilePath("B.txt"), new FilePath("C.txt") }; // Then Assert.False(ReferenceEquals(result, collection)); }