title: Substring under PropertyGroup in msbuild props not working when property is passed as argument to msbuild
body: <p>In my props file, i pass the <code>BUILD_VERSION</code> to <code>dotnet msbuild</code> using properties as <code>/p:BUILD_VERSION=1.2.3.4</code>. However, i get errors on when performing <code>Substring</code> operation on property <code>BuildVersion</code> which gets its value from : <code>BUILD_VERSION</code>.</p>
  
  <pre><code>&lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;IntermediateOutputPath&gt;./obj/&lt;/IntermediateOutputPath&gt;
      &lt;BuildVersion&gt;$(BUILD_VERSION)&lt;/BuildVersion&gt;
      &lt;InformationalVersion&gt;$(BuildVersion)&lt;/InformationalVersion&gt;
      &lt;BuildMajorVersion&gt;$([System.String]::Concat($(BuildVersion.Substring(0, $(BuildVersion.IndexOf('.')))), ".0.0.0"))&lt;/BuildMajorVersion&gt;
      &lt;AssemblyVersion&gt;$(BuildMajorVersion)&lt;/AssemblyVersion&gt;
      &lt;AssemblyFileVersion&gt;$(BuildMajorVersion)&lt;/AssemblyFileVersion&gt;
    &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>The error that i get is : <code>""".Substring(0,-1)" length should be inside the string</code></p>
  
  <p>I checked that <code>BUILD_VERSION</code> is present by printing in it in <code>Message</code>.</p>
  
  <pre><code>  &lt;Target Name="SetBuildVersions" BeforeTargets="BeforeBuild"&gt;
      &lt;Message Importance="High" Text="BUILD_VERSION=$(BUILD_VERSION)"/&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>It prints <code>BUILD_VERSION=1.2.3.4</code>.</p>
  
  <p>If i hardcode <code>&lt;BuildVersion&gt;1.2.3.4&lt;/BuildVersion&gt;</code> instead of <code>&lt;BuildVersion&gt;$(BUILD_VERSION)&lt;/BuildVersion&gt;</code> below, it works.</p>
  
  <p>If i use the <code>Substring</code> code inside a <code>Target</code> it works :</p>
  
  <pre><code>  &lt;Target Name="SetBuildVersions" BeforeTargets="BeforeBuild"&gt;
      &lt;PropertyGroup&gt;
        &lt;InformationalVersion&gt;$(BuildVersion)&lt;/InformationalVersion&gt;
        &lt;BuildMajorVersionOnly&gt;$([System.String]::Concat($(BuildVersion.Substring(0, $(BuildVersion.IndexOf('.')))), ".0.0.0"))&lt;/BuildMajorVersionOnly&gt;
        &lt;AssemblyVersion&gt;$(BuildMajorVersionOnly)&lt;/AssemblyVersion&gt;
        &lt;AssemblyFileVersion&gt;$(BuildMajorVersionOnly)&lt;/AssemblyFileVersion&gt;
      &lt;/PropertyGroup&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>Why can't i use the <code>Substring</code> inside normal <code>PropertyGroup</code> when passing <code>BUILD_VERSION</code> as property argument to <code>msbuild</code> ?</p>