TedToolkit.FileSystem.ProjectPaths
2026.7.15
See the version list below for details.
dotnet add package TedToolkit.FileSystem.ProjectPaths --version 2026.7.15
NuGet\Install-Package TedToolkit.FileSystem.ProjectPaths -Version 2026.7.15
<PackageReference Include="TedToolkit.FileSystem.ProjectPaths" Version="2026.7.15" />
<PackageVersion Include="TedToolkit.FileSystem.ProjectPaths" Version="2026.7.15" />
<PackageReference Include="TedToolkit.FileSystem.ProjectPaths" />
paket add TedToolkit.FileSystem.ProjectPaths --version 2026.7.15
#r "nuget: TedToolkit.FileSystem.ProjectPaths, 2026.7.15"
#:package TedToolkit.FileSystem.ProjectPaths@2026.7.15
#addin nuget:?package=TedToolkit.FileSystem.ProjectPaths&version=2026.7.15
#tool nuget:?package=TedToolkit.FileSystem.ProjectPaths&version=2026.7.15
TedToolkit.FileSystem.ProjectPaths
TedToolkit.FileSystem.ProjectPaths generates strongly typed DirectoryPath and FilePath members for the files and directories you explicitly select from the current Git work tree.
It provides compile-time path access without hard-coding paths throughout an application:
var repository = ProjectPaths.Git;
var project = ProjectPaths.Project;
var settings = ProjectPaths.src.App.appsettings_Development_json;
Only paths declared in the project file are generated. Selecting a directory never implicitly generates its children.
Requirements
- The project must be inside a Git work tree.
- The
gitexecutable must be available on the build machine'sPATH. - The generated code uses
TedToolkit.FileSystem.DirectoryPathandTedToolkit.FileSystem.FilePath; this dependency is included by the package.
Install
Add the package to the project that needs the generated paths:
<PackageReference Include="TedToolkit.FileSystem.ProjectPaths" Version="*" PrivateAssets="all" />
Select paths
Add one TedToolkitFileSystemPath item for every file, directory, or pattern that should become available through ProjectPaths. Paths are relative to the Git work tree root, not to the project file.
<ItemGroup>
<TedToolkitFileSystemPath Include="src/App/Assets" Kind="Directory" />
<TedToolkitFileSystemPath Include="src/App/*.json" Kind="File" />
<TedToolkitFileSystemPath Include="src/App/**/*.json" Kind="File" />
<TedToolkitFileSystemPath Include="src/App/appsettings.Development.json" Kind="File" />
</ItemGroup>
Kind accepts File, Directory, or Any; it defaults to Any. Use File or Directory when the expected path type is known.
Include supports these glob tokens:
| Token | Matches |
|---|---|
* |
Any characters within one path segment. src/App/*.json does not match files in child directories. |
? |
One character within one path segment. |
** |
Zero or more directory segments. src/App/**/*.json matches both src/App/appsettings.json and src/App/Settings/feature.json. |
Patterns select only entries whose Kind matches. A selected directory generates its Directory property, but never generates its files or child directories unless they are selected by another item.
Name is optional and applies only to files. Use it to override a generated file member name when a file name would be unclear or conflicts with another file member:
<TedToolkitFileSystemPath Include="src/App/appsettings.Development.json"
Kind="File"
Name="DevelopmentSettings" />
Generated API
Every project receives one generated ProjectPaths class in the project's root namespace:
public static class ProjectPaths
{
public static DirectoryPath Git { get; }
public static FilePath Project { get; }
}
ProjectPaths.Gitis the Git work tree root.ProjectPaths.Projectis the.csprojfile that references this package.- Each generated directory is a static class with a
Directory: DirectoryPathproperty. - Each generated file is a
FilePathproperty.
For the preceding configuration, usage looks like this:
var assetsDirectory = ProjectPaths.src.App.Assets.Directory;
var settingsFile = ProjectPaths.src.App.appsettings_Development_json;
The generated ProjectPaths class is placed in the project's RootNamespace. Import that namespace before using it from another namespace:
using MyProject;
var configuration = ProjectPaths.src.App.appsettings_Development_json;
Generated XML documentation contains the corresponding full path, so the path is visible in IntelliSense.
Member names
Directory names preserve their original casing. File names also preserve casing, while characters that are not valid in C# identifiers are replaced with one underscore. Consecutive invalid characters produce only one underscore.
| Path name | Generated member name |
|---|---|
appsettings.Development.json |
appsettings_Development_json |
my file-name.json |
my_file_name_json |
2026-report.json |
_2026_report_json |
class.json |
_class_json |
If two selected files produce the same member name, the build reports TTFS002. Set Name on one of the file items to resolve it.
Diagnostics
| Id | Meaning |
|---|---|
TTFS001 |
The project is not inside a Git work tree, or Git could not provide its root. |
TTFS002 |
Two selected paths produce the same generated member name. |
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- TedToolkit.FileSystem (>= 2026.7.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.9.11.1 | 93 | 9/11/2026 |
| 2026.8.3 | 111 | 8/3/2026 |
| 2026.7.15 | 109 | 7/15/2026 |
| 2.0.0 | 86 | 9/11/2026 |