title: >NET5.0 Increment Application Version
body: <p>I have a C# WPF project in Visual Studio 2019 that I'm trying to set the AssemblyVersion and AssemblyFileVersion of. The idea being that I am trying to set them to &quot;0.Months since project started.Days since this month started.Minutes since midnight&quot; to help with version control</p>
  <p>I have a Text Template file with the code below</p>
  <pre><code>using System.Reflection;
  
  [assembly: AssemblyVersion(&quot;&lt;#= this.Release #&gt;.&lt;#= this.MonthsSinceProjectStarted #&gt;.&lt;#= this.DaysSinceMonthStarted #&gt;.&lt;#= this.MinutesSinceMidnight  #&gt;&quot;)]
  [assembly: AssemblyFileVersion(&quot;&lt;#= this.Release #&gt;.&lt;#= this.MonthsSinceProjectStarted #&gt;.&lt;#= this.DaysSinceMonthStarted #&gt;.&lt;#= this.MinutesSinceMidnight  #&gt;&quot;)]
  
  &lt;#+
  int Release = 0;
   
  static DateTime ProjectStartedDate = new DateTime(year: 2022, month: 5, day: 20);
   
  int MonthsSinceProjectStarted = (int)((Int32.Parse(DateTime.Now.ToString(&quot;yyyy&quot;)) * 12) + Int32.Parse(DateTime.Now.ToString(&quot;MM&quot;))) - ((ProjectStartedDate.Year * 12) ProjectStartedDate.Month);
  int DaysSinceMonthStarted = (int)Int32.Parse(DateTime.Now.ToString(&quot;dd&quot;));
  int MinutesSinceMidnight = (int)DateTime.UtcNow.TimeOfDay.TotalMinutes;
  #&gt;
  </code></pre>
  <p>My .csproj file also looks like this</p>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
  
    &lt;PropertyGroup&gt;
      &lt;OutputType&gt;WinExe&lt;/OutputType&gt;
      &lt;TargetFramework&gt;net5.0-windows&lt;/TargetFramework&gt;
      &lt;RootNamespace&gt;LPG_Launcher&lt;/RootNamespace&gt;
      &lt;UseWPF&gt;true&lt;/UseWPF&gt;
      &lt;Company&gt;LowPoly Games&lt;/Company&gt;
      &lt;Authors&gt;LowPoly Games&lt;/Authors&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=&quot;'$(Configuration)|$(Platform)'=='Release|x64'&quot;&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
      &lt;DebugType&gt;none&lt;/DebugType&gt;
      &lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;
      &lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
      &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
      &lt;TransformOutOfDateOnly&gt;false&lt;/TransformOutOfDateOnly&gt;
      &lt;GenerateAssemblyInfo&gt;false&lt;/GenerateAssemblyInfo&gt;
      &lt;Optimize&gt;true&lt;/Optimize&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;
      &lt;DebugType&gt;full&lt;/DebugType&gt;
      &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
      &lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
      &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
      &lt;TransformOutOfDateOnly&gt;false&lt;/TransformOutOfDateOnly&gt;
      &lt;GenerateAssemblyInfo&gt;false&lt;/GenerateAssemblyInfo&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|AnyCPU'&quot;&gt;
      &lt;DebugType&gt;full&lt;/DebugType&gt;
      &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
      &lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
      &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
      &lt;TransformOutOfDateOnly&gt;false&lt;/TransformOutOfDateOnly&gt;
      &lt;GenerateAssemblyInfo&gt;false&lt;/GenerateAssemblyInfo&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=&quot;'$(Configuration)|$(Platform)'=='Release|AnyCPU'&quot;&gt;
      &lt;DebugType&gt;none&lt;/DebugType&gt;
      &lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;
      &lt;PlatformTarget&gt;x64&lt;/PlatformTarget&gt;
      &lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
      &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
      &lt;TransformOutOfDateOnly&gt;false&lt;/TransformOutOfDateOnly&gt;
      &lt;GenerateAssemblyInfo&gt;false&lt;/GenerateAssemblyInfo&gt;
      &lt;Optimize&gt;true&lt;/Optimize&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;Target Name=&quot;PostBuild&quot; AfterTargets=&quot;PostBuildEvent&quot;&gt;
      &lt;Exec Command=&quot;if $(ConfigurationName) == Release (&amp;#xD;&amp;#xA;   del /S *.pdb&amp;#xD;&amp;#xA;)&quot; /&gt;
    &lt;/Target&gt;
  
    &lt;PropertyGroup&gt;
      &lt;GenerateAssemblyInfo&gt;false&lt;/GenerateAssemblyInfo&gt;
      &lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
      &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
      &lt;TransformOutOfDateOnly&gt;false&lt;/TransformOutOfDateOnly&gt;
    &lt;/PropertyGroup&gt;
    
    &lt;ItemGroup&gt;
      &lt;None Include=&quot;VersionAutoIncrementer.tt&quot;&gt;
        &lt;Generator&gt;TextTemplatingFileGenerator&lt;/Generator&gt;
        &lt;LastGenOutput&gt;VersionAutoIncrementer.txt&lt;/LastGenOutput&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;Service Include=&quot;{508349b6-6b84-4df5-91f0-309beebad82d}&quot; /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;Import Project=&quot;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets&quot; /&gt;
  
  &lt;/Project&gt;
  
  </code></pre>
  <p>When I clean and build my solution, it builds a .cs file with the below code in it</p>
  <pre><code>
  using System.Reflection;
  
  [assembly: AssemblyVersion(&quot;0.0.20.673&quot;)]
  [assembly: AssemblyFileVersion(&quot;0.0.20.673&quot;)]
  
  
  </code></pre>
  <p>But checking the properties of the &quot;LPG Launcher.exe&quot; thats built is showing the version numbers to be &quot;0.0.0.0&quot;. Is this a suitable method of setting these values and if so, what am I doing incorrectly?</p>