Return to Snippet

Revision: 68723
at February 15, 2015 21:36 by padapara


Updated Code
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
     int major = 1; 
     int minor = 115; 

     string build = ""; 
     string revision = ""; 

     string error = "";

     DateTime now = DateTime.Now;

     try
     {
         using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
         {
             build = now.ToString("MMd"); 

             revision = now.ToString("HHmm"); 
         }
     }
     catch (Exception e)
     {
	 error = e.ToString();

         build = "0"; 
         revision = "0"; 
     }
 #>

 // 
 // This code was generated by a tool. Any changes made manually will be lost
 // the next time this code is regenerated.
 // 
  
 /* <#= error #> */

 using System.Reflection;

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

//[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

Revision: 68722
at February 15, 2015 11:52 by padapara


Updated Code
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
     int major = 0; 
     int minor = 5; 

     string build = ""; 
     string revision = ""; 

     string error = "";

     DateTime now = DateTime.Now;

     try
     {
         using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
         {
             build = now.ToString("MMd"); 

             revision = now.ToString("HHmm"); 
         }
     }
     catch (Exception e)
     {
	 error = e.ToString();

         build = "0"; 
         revision = "0"; 
     }
 #>

 // 
 // This code was generated by a tool. Any changes made manually will be lost
 // the next time this code is regenerated.
 // 
  
 /* <#= error #> */

 using System.Reflection;

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

//[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

Revision: 68721
at February 15, 2015 11:38 by padapara


Updated Code
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
     int major = 0; 
     int minor = 5; 

     string build = ""; 
     string revision = ""; 

	 string error = "";

     DateTime now = DateTime.Now;

     try
     {
         using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
         {
			 build = now.ToString("MMd"); 

             revision = now.ToString("HHmm"); 
         }
     }
     catch (Exception e)
     {
	     error = e.ToString();

         build = "0"; 
         revision = "0"; 
     }
 #>

 // 
 // This code was generated by a tool. Any changes made manually will be lost
 // the next time this code is regenerated.
 // 
  
 /* <#= error #> */

 using System.Reflection;

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

//[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

Revision: 68720
at February 15, 2015 11:35 by padapara


Updated Code
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
     int major = 0; 
     int minor = 5; 

     string build = ""; 
     string revision = ""; 

	 string error = "";

     DateTime now = DateTime.Now;

     try
     {
         using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
         {
			 // from https://oldhu.wordpress.com/2011/08/23/assemblyfileversion-format-and-limitation/

			 // It has to be the format of x.x.x.x and each x is a 16-bit number, therefore the max AssemblyFileVersion is 65535.65535.65535.65535

             // It�s a limitation of Windows, not .NET:

             // http://msdn.microsoft.com/en-gb/library/aa381058.aspx

             // FILEVERSION: Binary version number for the file. The version consists of two 32-bit integers, defined by four 16-bit integers.

			 build = now.ToString("MMd"); 

             revision = now.ToString("HHmm"); 
         }
     }
     catch (Exception e)
     {
	     error = e.ToString();

         build = "0"; 
         revision = "0"; 
     }
 #>

 // 
 // This code was generated by a tool. Any changes made manually will be lost
 // the next time this code is regenerated.
 // 
  
 /* <#= error #> */

 using System.Reflection;

// from http://blogs.codes-sources.com/jay/archive/2010/07/10/comment-versionner-efficacement-avec-les-attributs-assemblyversion-et-assemblyfileversion.aspx

// Pour éviter d'avoir ces problèmes de versions lors de la résolution des dépendances, il est possible de garder de garder constant le AssemblyVersion, et d'utiliser le AssemblyFileVersion 
// pour donner la version effective de l'assembly.

// La version présente dans le AssemblyFileVersion n'est pas utilisée par le Runtime .NET, mais est affichée dans les propriétés du fichier dans l'explorateur de Windows.

// On va donc avoir dans le fichier AssemblyVersion la version originale de l'application, et placer la même version dans AssemblyFileVersion, puis on va changer le AssemblyFileVersion 
// au fur et à mesure des différents correctifs publiés pour ces assemblies.

// Microsoft utilise cette technique pour versionner les assemblies de .NET, puisque si l'on prend l'assembly System.dll pour .NET 2.0, on peut constater que le AssemblyVersion est 2.0.0.0, 
// et que le AssemblyFileVersion est par exemple 2.0.50727.4927.

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

// from http://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio

// Setting only the 4th number to be * can be bad, as the version won't always increment. 

// The 3rd number is the number of days since the year 2000, and the 4th number is the number of seconds since midnight (divided by 2) [IT IS NOT RANDOM]. 

// So if you built the solution late in a day one day, and early in a day the next day, the later build would have an earlier version number. 
// I recommend always using X.Y.* instead of X.Y.Z.* because your version number will ALWAYS increase this way. 

//[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

Revision: 68719
at February 15, 2015 11:16 by padapara


Initial Code
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
     int major = 0; 
     int minor = 5; 

     string build = ""; 
     string revision = ""; 

	 string error = "";

     DateTime now = DateTime.Now;

     try
     {
         using(var f = File.OpenText(Host.ResolvePath("AssemblyVersion.cs")))
         {
			 // from https://oldhu.wordpress.com/2011/08/23/assemblyfileversion-format-and-limitation/

			 // It has to be the format of x.x.x.x and each x is a 16-bit number, therefore the max AssemblyFileVersion is 65535.65535.65535.65535

             // It’s a limitation of Windows, not .NET:

             // http://msdn.microsoft.com/en-gb/library/aa381058.aspx

             // FILEVERSION: Binary version number for the file. The version consists of two 32-bit integers, defined by four 16-bit integers.

			 build = now.ToString("MMd"); 

             revision = now.ToString("HHmm"); 
         }
     }
     catch (Exception e)
     {
	     error = e.ToString();

         build = "0"; 
         revision = "0"; 
     }
 #>

 // 
 // This code was generated by a tool. Any changes made manually will be lost
 // the next time this code is regenerated.
 // 
  
 /* <#= error #> */

 using System.Reflection;

// from http://blogs.codes-sources.com/jay/archive/2010/07/10/comment-versionner-efficacement-avec-les-attributs-assemblyversion-et-assemblyfileversion.aspx

// Pour éviter d'avoir ces problèmes de versions lors de la résolution des dépendances, il est possible de garder de garder constant le AssemblyVersion, et d'utiliser le AssemblyFileVersion 
// pour donner la version effective de l'assembly.

// La version présente dans le AssemblyFileVersion n'est pas utilisée par le Runtime .NET, mais est affichée dans les propriétés du fichier dans l'explorateur de Windows.

// On va donc avoir dans le fichier AssemblyVersion la version originale de l'application, et placer la même version dans AssemblyFileVersion, puis on va changer le AssemblyFileVersion 
// au fur et à mesure des différents correctifs publiés pour ces assemblies.

// Microsoft utilise cette technique pour versionner les assemblies de .NET, puisque si l'on prend l'assembly System.dll pour .NET 2.0, on peut constater que le AssemblyVersion est 2.0.0.0, 
// et que le AssemblyFileVersion est par exemple 2.0.50727.4927.

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

// from http://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio

// Setting only the 4th number to be * can be bad, as the version won't always increment. 

// The 3rd number is the number of days since the year 2000, and the 4th number is the number of seconds since midnight (divided by 2) [IT IS NOT RANDOM]. 

// So if you built the solution late in a day one day, and early in a day the next day, the later build would have an earlier version number. 
// I recommend always using X.Y.* instead of X.Y.Z.* because your version number will ALWAYS increase this way. 

//[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= build #>.<#= revision #>")]

Initial URL
assemblyVersionWithDate

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

Initial Title
AssemblyVersion.tt

Initial Tags

                                

Initial Language
C#