title: Visual Studio 2017 not loading AjaxMin MSBuild Task from specified path
body: <p>I'm attempting update an existing application so that it will load in Visual Studio 2017 (Enterprise - V15.2 (26430.12)) from Visual Studio 2015 (Enterprise) and having issues with the AjaxMin build task.</p>
  
  <p>In Visual Studio 2015, the AjaxMin build task is found in C:\Program Files (x86)\MSBuild\Microsoft\MicrosoftAjax.  Visual Studio 2017 looks for it in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft.  Given that all developers on the team may not have VS2017 Enterprise and we've had issues in the past with developers installing the wrong version, I'd like to have it use the AjaxMin NuGet package referenced in the solution.</p>
  
  <p>There are 3 projects in the solution that use the AjaxMin task.  I've updated all of them to have the following import:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0"&gt;
  ...
  &lt;Import Project="$(MSBuildProjectDirectory)\..\..\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMin.targets" /&gt;
  &lt;Target Name="BeforeBuild"&gt;
    &lt;ItemGroup&gt;
      &lt;JS Include="..." Exclude="..." /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;CSS Include="..." Exclude="..." /&gt;
    &lt;/ItemGroup&gt;
    &lt;AjaxMin Switches="..." JsSourceFiles="@(JS)" JsCombinedFileName="..." CssSourceFiles="@(CSS)" CssCombinedFileName="..." /&gt;
  &lt;/Target&gt;
  ...
  &lt;/Project&gt;
  </code></pre>
  
  <p>However, when the build happens, I receive an error saying it can't find the AjaxMin task in the default build extensions directory:</p>
  
  <blockquote>
    <p>The "AjaxMin" task could not be loaded from the assembly C:\Program
    Files (x86)\Microsoft Visual
    Studio\2017\Enterprise\MSBuild\Microsoft\MicrosoftAjax\AjaxMinTask.dll.
    Could not load file or assembly 'file:///C:\Program Files
    (x86)\Microsoft Visual
    Studio\2017\Enterprise\MSBuild\Microsoft\MicrosoftAjax\AjaxMinTask.dll'
    or one of its dependencies. The system cannot find the file specified.
    Confirm that the  declaration is correct, that the assembly
    and all its dependencies are available, and that the task contains a
    public class that implements Microsoft.Build.Framework.ITask.</p>
  </blockquote>
  
  <p>I've used the MSBuild <a href="https://msdn.microsoft.com/en-us/library/6yy0yx8d.aspx" rel="nofollow noreferrer">Message Task</a> to output the path and verified that it is correct by navigating to it from the command prompt.  I also tried using the <a href="https://msdn.microsoft.com/en-us/library/t41tzex2.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">UsingTask</a> with no luck there.</p>
  
  <p>Why is Visual Studio not looking for the AjaxMin DLL in the location I specified?</p>
  
  <p><strong>Update:</strong>
  I moved the import tag for AjaxMin to the top (right under the project tag) and it works now.  I don't understand why.</p>