File

Aliases

IEnumerable<FilePath> GetFiles(params string[] patterns)

returns an IEnumerable of FilePath's that match multiple glob patterns

IEnumerable<FilePath> filePaths = GetFiles("**/*.sln", "**/*.csproj");

Move(FilePath source, FilePath destination)

moves a file

MoveFiles("/from/source.txt", "/to/destination.txt");

Move(IEnumerable<FilePath> source, Directory destination)

moves a list of files to a folder

var source = new[] { new FilePath("/from/one.txt"), new FilePath("/from/two.txt") };
MoveFiles(source, new Directory("/to");

// /to/one.txt
// /to/two.txt 🐦

GetOutputAssemblies(FilePath slnOrProj, string config)

The FilePath and the build configuration will get the output files (dll or exe) and return them as an IEnumerable of FilePath

For a solution

// Solution output dll/exe's FilePath[] for 'Release' configuration
IEnumerable<FilePath> filePaths = GetOutputAssemblies(new FilePath("test.sln"), "Release");

For a project

// Project output dll/exe as FilePath[] for 'Custom' configuration
IEnumerable<FilePath> filePaths = GetOutputAssemblies(new FilePath("test.csproj"), "Custom");

The alias expects a valid .sln or a csproj file.

// throws ArgumentException("not a project or solution file")
GetOutputAssemblies(new FilePath("test.cs"), "Debug");

GetSolutionAssemblies(FilePath sln, string config)

Like GetOutputAssemblies but works for .sln files only.

// returns solution output dll/exe's FilePath[] for 'Release' configuration
IEnumerable<FilePath> filePaths = GetSolutionAssemblies(new FilePath("test.sln"), "Release");
// throws ArgumentException("not a solution file")
IEnumerable<FilePath> filePaths = GetSolutionAssemblies(new FilePath("test.csproj"), "Debug");

GetProjectAssembly(FilePath proj, string config)

Like GetOutputAssemblies but works for .csproj files only.

// returns solution output dll/exe FilePath for 'Release' configuration
IEnumerable<FilePath> filePaths = GetProjectAssembly(new FilePath("test.csproj"), "Release");
// throws ArgumentException("not a project file")
IEnumerable<FilePath> filePaths = GetProjectAssembly(new FilePath("test.sln"), "Debug");

GetMatchingFiles(FilePath file)

Locates files with the same name in the same directory, but different extensions.

The .pdb to your .dll as it were.

// Alias : GetMatchingFiles(FilePath file)
// /output/file.dll
// /output/file.xml
// /output/file.pdb
// output/another.dll

// matchingFiles.Length = 2
IEnumerable<FilePath> matchingFiles = GetMatchingFiles(new FilePath("/output/file.dll"));

matchingFiles[0]; // /output/file.xml
matchingFiles[1]; // /output/file.pdb

Extensions

Extension methods can be called on FilePath objects

FilePath.IsSolution()

Check if the file is a solution

new FilePath("test.sln").IsSolution(); // true

FilePath.IsProject()

Check if the file is a project

new FilePath("test.csproj").IsProject(); // true;
new FilePath("test.fsproj").IsProject(); // true;

FilePath.HasFileName(string fileName)

Check by the filename (includes extension)

new FilePath("/folder/testing.cs").HasFileName("testing.cs"); // true

results matching ""

    No results matching ""