更新:
有一个比最初提到的版本更新的版本,请在此处查看公告:https://devblogs.microsoft.com/dotnet/t4-command-line-tool-for-dotnet/
它位于
{VS_INSTALL_PATH}\Common7\IDE\TextTransformCore.exe。
TextTransform.exe
添加到您的项目文件中
(可以使用“添加现有项”、“复制并粘贴到项目文件夹中然后引用”等方式)
创建一个新的.tt文件,我的文件内容如下:<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#
var dateTimeNow = DateTime.Now.ToString();
#>
<#=dateTimeNow#>
Main
中完成的。static void Main(string[] args)
{
File.Delete("TextTemplate1.txt"); //delete the existing file, to make sure the code does what its supposed to do
Thread.Sleep(1000); //wait for filesystem to do its job
var proc = new Process
{
StartInfo =
{
FileName = "TextTransform.exe",
Arguments = "TextTemplate1.tt"
}
};
proc.Start();
proc.WaitForExit();
}
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
获取你的 .exe文件的吗?那个对我也没用。 - Rand Random
C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0
- BurnsBA