6

I am using MSBuild to generate some files using T4 and I was wondering if it would be possible to reference and use MSBuild properties within the T4 template?

I want to do something like this snippet:

Revision: <#=$(Revision)#>

This throws an error:

error CS1056: Compiling transformation: Unexpected character '$'

I'd prefer not to have to wrap the properties in a custom DLL and reference a C# class as a T4 property.

Any help would be much appreciated.

2 Answers 2

1

It should be possible to pass $(Revision) value via TextTransform command line -a option.

Add something like this into your template:

      [<#= this.Host.ResolveParameterValue("", "", "RevisionParameter") #>]

And into MsBuild script:

    TextTransform -a !!RevisionParameter!$(Revision)
0

You may use ResolveAssemblyReference, for example :

Revision: <#=Host.ResolveAssemblyReference("$(Revision)")#>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.