I simply want to build my t4 files via my azure build pipeline. I tried the following things:
Adding the following powershell script to my solution items :
$progFilesx86Path = [System.Environment]::ExpandEnvironmentVariables("%programfiles(x86)%")
$vsWherePath = Join-Path $progFilesx86Path "\Microsoft Visual Studio\Installer\vswhere.exe"
$textTransformLocation = & $vsWherePath -latest -find **\TextTransform.exe -format value
if (-Not(Test-Path $textTransformLocation)){
throw "Could not locate TextTransform.exe"
}
Get-ChildItem -Path .\ -Filter *.tt -r | % {
& "$textTransformLocation" $_.FullName -out $_.FullName.Replace(".tt", ".cs")
}
This script works fine when I call it with the powershell ISE and actually generates the .cs files in my project, but when I add a powershell task in my pipeline to execute it, nothing happens. My task description looks like:
- task: PowerShell@2
inputs:
filePath: '$(System.DefaultWorkingDirectory)/test.ps1'
When I run the pipeline it actually tells me the script has been executed succesfully (It also actually lists all found tt files via the command line), but the .cs files from tt have not been created.
So after that I tried to get my files to build via the visual studio build, adding the following to my project file:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" />
<PropertyGroup>
<TransformOnBuild>true</TransformOnBuild>
<!-- Other properties can be inserted here -->
</PropertyGroup>
This works when I build locally, but again doesn't generate files when the project is built via the pipeline.
Does anyone know what I am missing here or how I could get this task done?