Created
October 5, 2015 07:52
-
-
Save Tewr/03cccc8cfe2081f30aaf to your computer and use it in GitHub Desktop.
BuildTimeInfo Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ import namespace="System" #> | |
<#@ output extension=".cs" #> | |
<# | |
string datePattern = "fffssmmHHddMMyyyy"; | |
string buildTime = DateTime.Now.ToString(datePattern); | |
string humanReadableBuildTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"); | |
#>using System; | |
using System.Globalization; | |
public class BuildTimeInfo { | |
/// <summary> | |
/// The time this assembly was built (<#= humanReadableBuildTime#>) | |
/// </summary> | |
private static readonly DateTime buildTime = DateTime.ParseExact("<#= buildTime#>", "<#= datePattern#>", CultureInfo.InvariantCulture); | |
/// <summary> | |
/// Get the time this assembly was built (<#= humanReadableBuildTime#>) | |
/// </summary> | |
public static DateTime BuildTime { | |
get | |
{ | |
return buildTime; | |
} | |
} | |
/// <summary> | |
/// A string description of when this assembly was built (returns "<#= humanReadableBuildTime#>") | |
/// </summary> | |
public const string BuildTimeString = "<#= humanReadableBuildTime#>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project> | |
<ItemGroup> | |
<None Include="RunT4.bat" /> | |
<None Include="BuildTimeInfo.tt"> | |
<Generator>TextTemplatingFileGenerator</Generator> | |
<LastGenOutput>BuildTimeInfo.cs</LastGenOutput> | |
</None> | |
</ItemGroup> | |
<PropertyGroup> | |
<PreBuildEvent>..\..\RunT4.bat ..\..</PreBuildEvent> | |
</PropertyGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM äöäé | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
:: set the working dir (default to current dir) | |
set wdir=%cd% | |
if not (%1)==() set wdir=%1 | |
:: set the file extension (default to vb) | |
set extension=cs | |
if not (%2)==() set extension=%2 | |
echo executing transform_all from %cd% | |
:: create a list of all the T4 templates in the working dir | |
dir %wdir%\*.tt /b /s > t4list.txt | |
echo the following T4 templates will be transformed: | |
type t4list.txt | |
:: transform all the templates | |
for /f "delims=" %%d in (t4list.txt) do ( | |
set file_name=%%d | |
set file_name=!file_name:~0,-3!.%extension% | |
echo: \--^> !file_name! | |
echo Running "%COMMONPROGRAMFILES(x86)%\microsoft shared\TextTemplating\12.0\TextTransform.exe" -out "!file_name!" "%%d" | |
"%COMMONPROGRAMFILES(x86)%\microsoft shared\TextTemplating\12.0\TextTransform.exe" -out "!file_name!" "%%d" | |
) | |
echo transformation complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested with Visual Studio Professional 2013