title: The “GetReferenceNearestTargetFrameworkTask” task was not found
body: <p><strong>Given:</strong> My local system references MSBuild at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSbuild.exe". My automated build server (Jenkins) does not have this version of MSBuild so I used chocolatey to download microsoft-build-tools.</p>
  
  <p><strong>Problem:</strong> My visual studio project compiles successfully locally but won't compile successfully on my automated build server (Jenkins) due to a ReferenceAssembly error:</p>
  
  <blockquote>
    <p>C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.</p>
  </blockquote>
  
  <p>I've searched online and found a possible solution <a href="https://developercommunity.visualstudio.com/content/problem/137779/the-getreferencenearesttargetframeworktask-task-wa.html" rel="nofollow noreferrer">https://developercommunity.visualstudio.com/content/problem/137779/the-getreferencenearesttargetframeworktask-task-wa.html</a> where the powershell script modifies Microsoft Build Tools installer:</p>
  
  <pre><code>Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" --quiet --add Microsoft.VisualStudio.Component.NuGet.BuildTools --add Microsoft.Net.Component.4.6.2.TargetingPack --norestart --force' -Wait -PassThru
  </code></pre>
  
  <p>I ran the script and I could see that it modifies the installer to select the specified target 4.6.2. However, the target package 4.6.2 is not present in the path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework". I think it successfully downloaded the package one time but I deleted it to see if it was reproducible in my build server (Jenkins). </p>
  
  <p>I don't want to manually paste the v4.6.2 target package from my local system to the build server. Any ideas on how to resolve this reference assembly problem?</p>