Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use TextTransform (tt files) into the Azure Devops pipeline

Is it possible to transform the **/*.tt file into a *.cs file. Using Azure Devops pipeline?

Otherwise is there a CLI command available for Dotnet core using TextTransform ?

I already test : T5.TextTransform.Tool but is don't work (and deprecated)

Thanks for your help

like image 417
btbenjamin Avatar asked Oct 18 '25 14:10

btbenjamin


2 Answers

How i solve this problem using Devops pipeline + script:

  1. As mention @Leo Liu-MSFT Install dotnet-t4

install global -g

enter image description here

  1. Create powershell script and find tt file

Seach all *.tt file and convert them with the t4 command

enter image description here

Get-ChildItem -Path .\ -Filter *.tt -Recurse -File -Name| ForEach-Object {
    $file = [System.IO.Path]::GetFileName($_);
    $directory = [System.IO.Path]::GetDirectoryName($_)
    "Conversion file : " + $file
    t4 "$directory\$file" -I="$directory"
}

NOTE : It is important to place the T4.ps1 file in the parent directory of your *.tt files

like image 182
btbenjamin Avatar answered Oct 20 '25 05:10

btbenjamin


Is it possible to transform the **/*.tt file into a *.cs file. Using Azure Devops pipeline?

The answer is yes.

According to the state of the package T5.TextTransform.Tool:

T5 was a stopgap measure for a time when Mono.TextTemplating was not available for .NET Core. Now that that is no longer the case, T5 is not needed and no longer being maintained. Use Mono.TextTemplating's dotnet-t4 instead.

enter image description here

So, we could use the Mono.TextTemplating instead of T5.TextTransform.Tool.

Besides, there is also an implementation of the TextTransform.exe command-line tool, we could use the command line to transform the .tt file into .cs file:

"%CommonProgramFiles%\Microsoft Shared\TextTemplating\1.2\texttransform.exe" -out %1.cs -P %2 -P "%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.5" %1.tt

Check this thread for some more details.

Hope this helps.

like image 29
Leo Liu-MSFT Avatar answered Oct 20 '25 03:10

Leo Liu-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!