Scotec.T4 3.0.0

dotnet add package Scotec.T4 --version 3.0.0
                    
NuGet\Install-Package Scotec.T4 -Version 3.0.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="Scotec.T4" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Scotec.T4" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Scotec.T4" />
                    
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 Scotec.T4 --version 3.0.0
                    
#r "nuget: Scotec.T4, 3.0.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 Scotec.T4@3.0.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=Scotec.T4&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Scotec.T4&version=3.0.0
                    
Install as a Cake Tool

Scotec.T4 � Runtime T4 Text Template Generator

Scotec.T4 is an in-process T4 text template parser, compiler, and generator for .NET. It allows you to parse and execute T4 text templates at runtime, with no dependency on Visual Studio.

Key Features

  • Parse, compile, and execute .t4 template files at runtime
  • Load templates from files or directly from strings
  • Pass typed parameters to templates via a dictionary
  • Support for C# and Visual Basic templates
  • import, assembly, parameter, and include directives
  • Configurable line-ending style (CRLF, LF, CR, �)
  • Macro substitution (%MacroName%) in directive attributes
  • Optional code-behind files (codefile attribute)
  • Precompile multiple templates asynchronously for high-load scenarios
  • Supports .NET 8 and .NET 10

Installation

dotnet add package Scotec.T4

Quick Start

Template file � HelloWorld.t4

<#@ template language="C#" #>
Hello World!

Generate output

using Scotec.T4;

var generator = new Generator();
var template  = T4Template.FromFile("HelloWorld.t4");

string result = generator.Build(template).Generate(null);
Console.WriteLine(result); // Hello World!

Pass parameters

<#@ template language="C#" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ parameter type="IList<string>" name="friends" #>
<# foreach (var friend in friends) { #>
Hello <#= friend #>!
<# } #>
var parameters = new Dictionary<string, object>
{
    { "friends", new List<string> { "Mary", "Peter", "Paul" } }
};

string result = generator.Build(template).Generate(parameters);

Documentation

Document Description
Getting Started Installation and your first template
Template Syntax Directives, control blocks, and escaping
API Reference Generator, T4Template, T4Options, TextGenerator
Advanced Topics Precompilation, high-load, macros, error handling

License

See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.0.0 316 5/29/2026
2.0.0-dev.58 279 8/25/2024
2.0.0-dev.53 166 8/17/2024
2.0.0-dev.52 156 8/17/2024
2.0.0-dev.50 162 8/17/2024
2.0.0-dev.49 157 8/17/2024
2.0.0-dev.48 148 8/17/2024