Workspace Configuration
Place a cstemplate.config.json file in your project folder (or any parent
folder) to configure output locations, NuGet package references, and local
assembly references. The CLI searches upward from the template file's directory
until it finds one, so a single config file can cover an entire project tree.
Schema
{
"outputRoot": "../generated",
"project": "./MyProject.csproj",
"nugetPackages": [
"Humanizer.Core",
"Microsoft.Data.SqlClient"
],
"references": [
"path/to/LocalAssembly.dll"
]
}
Fields
outputRoot
Output directory for generated files, relative to the config file.
If omitted, each template writes to a generated/ folder adjacent to itself.
Can be overridden at runtime with the --output CLI argument.
project
Path to the template project's .csproj file, relative to the config file.
Required when nugetPackages is specified. cstemplate reads the project's
obj/project.assets.json (generated by dotnet restore) to resolve package
versions and transitive dependencies.
Note: Run
dotnet restoreon the project whenever you add or update NuGet package references. cstemplate will report a clear error if the assets file is missing or out of date.
nugetPackages
An array of NuGet package IDs to make available to templates at compile and execution time.
Specify package IDs only — no versions. Versions are taken from whatever the project has restored. Transitive dependencies are resolved automatically.
"nugetPackages": [
"Humanizer.Core",
"Microsoft.Data.SqlClient"
]
Packages with native dependencies (such as Microsoft.Data.SqlClient, which
requires the SNI native library) are handled automatically — cstemplate
resolves native libraries from the runtimes/ folder of the relevant packages.
references
An array of paths to local .dll assemblies, relative to the config file.
Use this to reference assemblies that are not available as NuGet packages.
"references": [
"../libs/MyLocalLibrary.dll"
]
Discovery
cstemplate searches for cstemplate.config.json by walking up the directory
tree from the template file's location. The first file found is used. This
means you can:
- Place a single config at the solution root to apply to all templates
- Override settings for a specific folder by adding a closer config file
If no config file is found, default behaviour applies: output goes to
generated/ next to each template, and no additional references are loaded.