title: How can I subtract two dates in msbuild?
body: <p>Since .net core does not support auto-version numbering, I am manually trying to manipulate msbuild in order to auto-generate a version number based on build date.</p>
  
  <p>I have the following property group:</p>
  
  <pre><code>&lt;PropertyGroup&gt;
      &lt;CurrentDate&gt;$([System.DateTime]::UtcNow.ToString(o))&lt;/CurrentDate&gt;
      &lt;SecondsSinceMidnight&gt;$(([System.DateTime]::UtcNow - [System.DateTime]::UtcNow.Date).TotalSeconds)&lt;/SecondsSinceMidnight&gt;
      &lt;Version&gt;$([System.DateTime]::UtcNow.Year).$([System.DateTime]::UtcNow.Month).$([System.DateTime]::UtcNow.Day).$(SecondsSinceMidnight)&lt;/Version&gt;
    &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>the <code>CurrentDate</code> property works great but I can't seem to get the <code>SecondsSinceMidnight</code> to work.  The error it gives is:</p>
  
  <blockquote>
    <p>The expression "([System.DateTime]::UtcNow - [System.DateTime]::UtcNow.Date).TotalSeconds" cannot be evaluated. </p>
  </blockquote>
  
  <p>I suspect the issue is either with the minus sign or the extra parenthesis, but I am having trouble finding out the correct way to write this operation.</p>