title: Get the correct $(VisualStudioVersion) for VS 2017 inside a MSBuild file
body: <p>I have a MSBuild file to publish a solution (created in VS 2013 and ported to VS 2017) to a remote server. The offending line is this one:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;PropertyGroup&gt;
      &lt;VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''"&gt;10.0&lt;/VisualStudioVersion&gt;
      &lt;VSToolsPath Condition="'$(VSToolsPath)' == ''"&gt;$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)&lt;/VSToolsPath&gt;
  &lt;/PropertyGroup&gt; 
  </code></pre>
  
  <p>When I run the command:</p>
  
  <pre><code>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild" WebSite1_Web_configs.build /p:Configuration=Integracion;Platform="AnyCPU" /p:VisualStudioVersion=15.0
  </code></pre>
  
  <p>After some compilation, it ends up with this error:</p>
  
  <pre><code>Error MSB4062 The "TransformXml" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll
  </code></pre>
  
  <p>Of course it can't be loaded, because the version should be 15.0, not 12.0.</p>
  
  <p><strong>Things I have tried:</strong></p>
  
  <ul>
  <li><p>Adding the <code>/p:VisualStudioVersion=15.0</code> to the command where I call MSBuild. It doesn't work.</p></li>
  <li><p>Changing, inside the <strong>*.csproj</strong> file, the element:</p></li>
  </ul>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  </code></pre>
  
  <p>For:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  </code></pre>
  
  <p>It doesn't work.</p>
  
  <p>So, how can I get the correct VS version with <code>$(VisualStudioVersion)</code> inside the MSBuild file without having to hardcode it?</p>