I want to build my .tt file on every build. I found this solution (Get Visual Studio to run a T4 Template on every build, answer by Cheburek) and got it running by following the steps
- Install Visual Studio SDK
- Install Visual Studio 2010 Modeling and Visualization SDK
- Adding the import for
Microsoft.TextTemplating.targets
and<TransformOnBuild>true</TransformOnBuild>
to my .csproj
My problem now is:
I am using the following assembly import in my T4 file:
<#@ assembly name="$(TargetPath)" #>
<#@ import namespace="My.Example.Namespace.Path" #>
I need this because I need to access a class which is defined in the same project. But now (I think because the tt-transformation is the first thing that is done on building) I cannot use this namespace import because the following error occurs on building:
Error Compiling transformation: Metadata file '$(TargetPath)' could not be found.
The T4-file was working before when it was used "normal" (file generation on saving the T4 file)
Is it somehow possible to execute the T4-transformation (as last build-step) so I can access $(TargetPath)
without problems in my T4-file?