I'm in desperate need to generate HTML output with T4 in C#.
I'm using Runtime-T4-Files and chose as option "TextTemplatingFilePreprocessor" instead of "TextTemplatingFileGenerator".
My "MyTemplate.tt"-File contains:
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
foo
My "Program.cs"-File contains:
using System;
namespace T4MS
{
class Program
{
static void Main(string[] args)
{
string output = new MyTemplate().TransformText();
Console.WriteLine(output);
}
}
}
What am I missing that following error occurs:
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand Fehler CS1069 Der Typname "CompilerErrorCollection" konnte nicht im Namespace "System.CodeDom.Compiler" gefunden werden. Dieser Typ wurde an Assembly "System.CodeDom, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzufügen. T4MS C:\Users\figaro\source\repos\T4MS\T4MS\MyTemplate.cs 47 Aktiv
Basically this error tells me to add an assembly reference "System.CodeDom", thrown by my auto generated "MyTemplate.cs"-File.
So I tried to add the "lacking" assembly with <#@ template language="C#" #> <#@ import namespace="System.CodeDom" #> or <#@ assembly name="System.CodeDom" #>in my tt-File.