T4Studio.Engine 0.1.0

dotnet add package T4Studio.Engine --version 0.1.0
                    
NuGet\Install-Package T4Studio.Engine -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="T4Studio.Engine" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="T4Studio.Engine" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="T4Studio.Engine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add T4Studio.Engine --version 0.1.0
                    
#r "nuget: T4Studio.Engine, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package T4Studio.Engine@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=T4Studio.Engine&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=T4Studio.Engine&version=0.1.0
                    
Install as a Cake Tool

T4 Studio

CI NuGet

T4 Studio is a modernized distribution of the upstream T4 text templating engine. It processes Visual Studio-compatible .tt templates from the command line, from MSBuild, or through the library API.

This fork is based on Mono.TextTemplating / mono/t4. Existing .tt templates remain supported. Project, package, folder, assembly, and runtime namespaces now use the T4 Studio identity, while the Visual Studio-compatible Microsoft.VisualStudio.TextTemplating API surface remains available where implemented.

Why It Exists

T4 is still useful for practical code generation, but many projects need a current .NET build, Roslyn compilation, NuGet packaging, and editor support outside the original Visual Studio-only workflow. T4 Studio focuses on those areas while preserving the behavior expected by existing templates.

Current focus:

  • Modern Roslyn-backed template compilation.
  • NuGet packages for engine, CLI, and MSBuild integration.
  • VS Code and Visual Studio editing experience.
  • Clear diagnostics, repeatable builds, and release automation.

Packages

Package Purpose
T4Studio.Engine Core T4 engine library. The assembly is T4Studio.Engine; the runtime namespace is T4Studio.
T4Studio.Cli .NET global tool that exposes the t4studio command.
T4Studio.Build MSBuild integration for transforming .tt files during dotnet build.

There is not a separate T4Studio.Roslyn package yet; Roslyn support is currently part of T4Studio.Engine. T4Studio.VSCode and T4Studio.Debugging are not NuGet packages in this repository at this time. The repo does include editor extension sources.

Install

Install the CLI:

dotnet tool install -g T4Studio.Cli

Install the engine library:

dotnet add package T4Studio.Engine

Install MSBuild integration:

<PackageReference Include="T4Studio.Build" Version="0.1.0" PrivateAssets="all" />

CLI Usage

t4studio template.tt
t4studio -o output.cs template.tt
t4studio -c MyNamespace.MyTemplate template.tt
t4studio -r MyAssembly.dll -u System.Linq -I templates -P lib -o output.cs template.tt

Useful options:

-o, --out=VALUE   Output file
-r=VALUE          Reference assembly, repeatable
-u=VALUE          Import namespace, repeatable
-I=VALUE          Include search path, repeatable
-P=VALUE          Reference search path, repeatable
-dp=VALUE         Directive processor as name!class!assembly
-a=VALUE          Parameter as name!value
-c=VALUE          Preprocess into namespace.class

Library Usage

The library API uses the T4Studio namespace:

using T4Studio;

var generator = new TemplateGenerator();
generator.Refs.Add(typeof(MyType).Assembly.Location);
generator.Imports.Add("System.Linq");
generator.AddParameter(null, null, "UserName", "Alice");
generator.ProcessTemplate("template.tt", "output.txt");

For DI-aware hosting:

using T4Studio.Hosting;

var host = new TemplatingHostBuilder(serviceProvider)
    .WithAssemblyReference(typeof(MyService).Assembly.Location)
    .WithImport("System.Linq")
    .WithParameter(null, null, "ConnectionString", connectionString)
    .Build();

MSBuild Usage

T4Studio.Build auto-discovers .tt files and transforms them after build.

<PropertyGroup>
  <EnableDefaultT4Items>true</EnableDefaultT4Items>
</PropertyGroup>

<ItemGroup>
  <T4PostBuildTemplate Include="Templates\*.tt">
    <LastGenOutput>$(OutDir)%(Filename).generated.cs</LastGenOutput>
    <T4Param_TargetAssembly>$(TargetPath)</T4Param_TargetAssembly>
  </T4PostBuildTemplate>
</ItemGroup>

Any item metadata named T4Param_<Key> is passed to the template as a parameter.

Compatibility

T4 Studio keeps compatibility with existing .tt templates as the primary constraint. That means:

  • Existing T4 syntax remains supported: <# #>, <#= #>, <#+ #>, and <#@ #>.
  • T4 Studio runtime APIs use the T4Studio namespace.
  • The Visual Studio-compatible Microsoft.VisualStudio.TextTemplating API surface remains available where implemented.
  • Upstream copyright and MIT license notices are preserved.

Build

dotnet restore
dotnet build -c Release

Test

dotnet test -c Release

Focused test examples:

dotnet test tests/T4Studio.Tests -c Release --filter "FullyQualifiedName~Roslyn"
dotnet test tests/T4Studio.Tests -c Release --filter "FullyQualifiedName~EdgeCases"

Pack

dotnet pack -c Release -o ./artifacts/packages

Expected NuGet outputs:

  • T4Studio.Engine.0.1.0.nupkg
  • T4Studio.Engine.0.1.0.snupkg
  • T4Studio.Cli.0.1.0.nupkg
  • T4Studio.Cli.0.1.0.snupkg
  • T4Studio.Build.0.1.0.nupkg
  • T4Studio.Build.0.1.0.snupkg

Editor Extensions

The repository currently contains:

  • .vscode/extensions/t4-syntax - VS Code syntax highlighting extension source.
  • src/T4Studio.Vsix - Visual Studio extension project for T4 language support.

These are editor extension assets, not NuGet packages.

Release

Packages are built by .github/workflows/ci.yml. When a tag matching v*.*.* is pushed, the same workflow publishes to NuGet using NuGet trusted publishing and the production GitHub environment.

git tag v0.1.0
git push origin v0.1.0

No NuGet API key is required. NuGet must trust repository jkljajic/T4Studio, workflow ci.yml, and environment production.

See docs/release.md for the full checklist.

Upstream Attribution

T4 Studio is based on Mono.TextTemplating / mono/t4. The original implementation and compatibility work came from the Mono project and community contributors. This fork preserves upstream attribution and license notices while preparing a modern NuGet-distributed project under the T4 Studio identity.

License

This project uses the MIT license, matching the existing upstream licensing in this repository. Keep the existing copyright and license notices when redistributing source or packages.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on T4Studio.Engine:

Package Downloads
T4Studio.Build

MSBuild integration for T4 Studio that transforms .tt files during dotnet build.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 149 7/2/2026