Skip to content

Instantly share code, notes, and snippets.

@georgepaoli
Created August 11, 2017 18:25
Show Gist options
  • Save georgepaoli/4273f3d1240458fdd13620d560705446 to your computer and use it in GitHub Desktop.
Save georgepaoli/4273f3d1240458fdd13620d560705446 to your computer and use it in GitHub Desktop.
Custom build version number in dotnet
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BeforeBuild">
<!-- https://stackoverflow.com/a/6472195/2076784 -->
<PropertyGroup>
<Year>$([System.DateTime]::Now.ToString("yyyy"))</Year>
<Month>$([System.DateTime]::Now.ToString("MM"))</Month>
<Date>$([System.DateTime]::Now.ToString("dd"))</Date>
<Time>$([System.DateTime]::Now.ToString("HHmm"))</Time>
<AssemblyFileVersionAttribute>[assembly:System.Reflection.AssemblyFileVersion("$(Year).$(Month).$(Date).$(Time)")]</AssemblyFileVersionAttribute>
</PropertyGroup>
<WriteLinesToFile File="Properties\VersionInfo.cs" Lines="$(AssemblyFileVersionAttribute)" Overwrite="true">
</WriteLinesToFile>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment