The “EntityClean” task could not be loaded from th

2019-08-12 08:04发布

问题:

I've imported VS2010 project file into a VS2012. Although import succeeds, there is following error when I tried to build the solution:

Error 3 The "EntityClean" task could not be loaded from the assembly c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Data.Entity.Build.Tasks.dll. Could not load file or assembly 'file:///c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Data.Entity.Build.Tasks.dll' or one of its dependencies. The module was expected to contain an assembly manifest. 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. DefinitiveHC.Data

Project was targetting framework 4.0 in both VS2010 and VS2012.

Any clues on how I might solve this issue?

回答1:

This is something that you see in the error list window. To see the actual issue, open the output window to see the actual issue. To resolve do the following:

  • Navigate to "C:\Windows\Microsoft.NET\Framework\v4.0.30319".
  • Copy Microsoft.Data.Entity.Build.Tasks.dll.
  • Paste this to the location "C:\Program Files (x86)\MSBuild\12.0\Bin"


回答2:

I found your question while researching so I thought I would answer it here too. I found an answer in this other question that set me on the right path to what I think may be a better answer(detailed below).

I give a lot of credit to Andy Mahaffey's answer, without it I would not have found what I did. I followed along his line of research but didn't like the idea of just changing the UsingTasks' attributes. I opened up the "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Data.Entity.targets" file and I found the first thing it says after the opening Project element is this comment:

  <!-- This .targets file can be used by updating Microsoft.Common.targets to 
         include the line below (as the last import element just before the end project tag)
      <Import Project="$(MSBuildBinPath)\Microsoft.Data.Entity.targets" Condition="Exists('$(MSBuildBinPath)\Microsoft.Data.Entity.targets')"/>
  -->

I followed it's suggestion and presto, problems solved.

I hope this helps!

TLDR

Paste the line below as the last element before the tag in the following file. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets

<Import Project="$(MSBuildBinPath)\Microsoft.Data.Entity.targets" Condition="Exists('$(MSBuildBinPath)\Microsoft.Data.Entity.targets')"/>