0

I have Nuget.targets file referenced by all projects in my solution for restoring packages before build. I have two tasks:

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> 

and

<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">.

My build fails at <SetEnvironmentVariable EnvKey="EnableNuGetPackageRestore" EnvValue="true" /> with error

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.

ignoring my explicit direction to use Microsoft.Build.Tasks.Core.dll.

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

Did I forget to override some setting or, maybe, MsBuild caches this somehow?

Sovent
  • 119
  • 2
  • 13
  • which version of VS / msbuild are you using to run the project? it looks like the VS 2013 version is involved somehow. – Martin Ullrich Jun 06 '17 at 19:26
  • Also, are you sure that this fails when the shown definition of the task is active? there may be a similar `` element that overrides yours - or an old version may be cached in VS. – Martin Ullrich Jun 06 '17 at 19:28
  • Im using Visual Studio 2015 with MSBuild 14. There are MSBuild parameters: `/m:2 /nr:false /tv:14.0 /p:VisualStudioVersion=14.0 /v:d`. And I am sure, that shown task is supposed to be executed, but I am not sure that there are no cached values, because I don't know anything about caching in MSBuild – Sovent Jun 07 '17 at 07:21

0 Answers0