Posted By


padapara on 02/15/15

Tagged


Statistics


Viewed 275 times
Favorited by 0 user(s)

AssemblyVersion.tt


/ Published in: C#
Save to your folder(s)

T4 template for put the date in build number (without year)


Copy this code and paste it in your HTML
  1. <#@ template debug="false" hostspecific="true" language="C#" #>
  2. <#@ import namespace="System.IO" #>
  3. <#@ output extension=".cs" #>
  4. <#
  5. int major = 1;
  6. int minor = 115;
  7.  
  8. string build = "";
  9. string revision = "";
  10.  
  11. string error = "";
  12.  
  13. DateTime now = DateTime.Now;
  14.  
  15. try
  16. {
  17. using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
  18. {
  19. build = now.ToString("MMd");
  20.  
  21. revision = now.ToString("HHmm");
  22. }
  23. }
  24. catch (Exception e)
  25. {
  26. error = e.ToString();
  27.  
  28. build = "0";
  29. revision = "0";
  30. }
  31. #>
  32.  
  33. //
  34. // This code was generated by a tool. Any changes made manually will be lost
  35. // the next time this code is regenerated.
  36. //
  37.  
  38. /* <#= error #> */
  39.  
  40. using System.Reflection;
  41.  
  42. [assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]
  43.  
  44. //[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

URL: assemblyVersionWithDate

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.