Reputation: 778
I'm having issues just creating the most basic of Assembly Information
using T4 - can anyone give me a hand?
I simply want the code below to generate a version number, manually so I can see that it works but the compiled .cs
file doesn't have the information it should.
Here's the code:
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".cs" #>
<#
int major = 5;
int minor = 0;
int build = 0;
int revisions = 0;
// TODO: Write code here to automatically generate a version
string version = String.Format("{0}.{1}.{2}.{3}",
major,
minor,
build,
revisions);
#>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
using System.Reflection;
[assembly: AssemblyVersion("<#= version #>")]
[assembly: AssemblyFileVersion("<#= version #>")]
Here's the expected result:
using System.Reflection;
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
And here's the actual result - which does not have any of the assembly code above.
This is similar to a few questions I've reviewed like these: this, this and this but even following their specific use cases, I've not been able to produce a .cs file that has the AssemblyVersion and AssemblyFileVersion attributes I'm expecting
Upvotes: 1
Views: 754
Reputation: 1590
From the output, it looks like you have the .tt file configured as a runtime file generator rather than a design time generator.
Check the Custom Tool property for the file. It should be TextTemplateFileGenerator, not TextTemplatingFilePreprocessor:
Upvotes: 1