title: MsBuild ignores my assembly definition for CodeTaskFactory
body: <p>I have Nuget.targets file referenced by all projects in my solution for restoring packages before build.
  I have two tasks:</p>
  
  <pre><code>&lt;UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"&gt; 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"&gt;.
  </code></pre>
  
  <p>My build fails at <code>&lt;SetEnvironmentVariable EnvKey="EnableNuGetPackageRestore" EnvValue="true" /&gt;</code> with error</p>
  
  <blockquote>
    <p>The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll' or one of its dependencies. The system cannot find the file specified.</p>
  </blockquote>
  
  <p>ignoring my explicit direction to use Microsoft.Build.Tasks.Core.dll. </p>
  
  <p>It worked until I put /tv:14.0 in MsBuild parameters and changed Microsoft.Build.Tasks.v4.0.dll to Microsoft.Build.Tasks.Core.dll</p>
  
  <p>Did I forget to override some setting or, maybe, MsBuild caches this somehow?</p>