Last active
July 22, 2017 16:18
-
-
Save pardeike/c36c4007b2855bc85950b59ade935bac to your computer and use it in GitHub Desktop.
AssemblyInfo.cs template with automatic version number calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- add this to the end of the Project --> | |
<Target Name="TransformOnBuild" BeforeTargets="BeforeBuild"> | |
<PropertyGroup> | |
<!-- CHANGE TO YOUR CORRECT PATH, THIS IS FOR VISUAL STUDIO 2017 COMMUNITY EDITION --> | |
<_TransformExe>$(MSBuildExtensionsPath)\..\Common7\IDE\TextTransform.exe</_TransformExe> | |
<_TextTransform>$(ProjectDir)Properties\AssemblyInfo.tt</_TextTransform> | |
<_TextTransformResult>$(ProjectDir)Properties\AssemblyInfo.cs</_TextTransformResult> | |
</PropertyGroup> | |
<Exec Command="del "$(_TextTransformResult)"" /> | |
<Exec Command=""$(_TransformExe)" "$(_TextTransform)" -out "$(_TextTransformResult)"" /> | |
</Target> | |
<!-- also include this AssemblyInfo.tt in the Properties folder | |
<#@ template language="C#" #> | |
using System.Reflection; | |
using System.Runtime.InteropServices; | |
[assembly: AssemblyTitle("TITLE")] | |
[assembly: AssemblyDescription("")] | |
[assembly: AssemblyConfiguration("")] | |
[assembly: AssemblyCompany("Andreas Pardeike")] | |
[assembly: AssemblyProduct("PRODUCTNAME")] | |
[assembly: AssemblyCopyright("Copyright © xxxx")] | |
[assembly: AssemblyTrademark("")] | |
[assembly: AssemblyCulture("")] | |
[assembly: ComVisible(false)] | |
[assembly: Guid("00000000-0000-0000-0000-000000000000")] | |
[assembly: AssemblyVersion("<#= this.BaseVersion #>.<#= this.RevisionNumber #>")] | |
[assembly: AssemblyFileVersion("<#= this.BaseVersion #>.<#= this.RevisionNumber #>")] | |
<#+ | |
// you can go all in here, but we just change the 1.0.0.xxxx part as an example | |
string BaseVersion = "1.0.0"; | |
int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2017,7,19)).TotalSeconds % 10000; | |
#> | |
--> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment