即使已安装MSBuild社区任务也无法加载

时间:2018-12-11 11:20:27

标签: c# wpf msbuild-task

我有一个WPF应用程序,大约一年没有使用,现在我有了新的PC。 当我从git克隆应用程序并尝试运行它时,出现此错误:

Severity    Code    Description Project File    Line    Suppression State
Error       The "MSBuild.Community.Tasks.AssemblyInfo" task could not be loaded from the assembly D:\MyData\SourceCodes\Library\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> 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.      

当我尝试从此处安装Microsoft.Build.Utilities.Core时:

https://www.nuget.org/packages/Microsoft.Build.Utilities.Core/

我收到此错误:

Install-Package : Could not install package 'Microsoft.Build.Utilities.Core 15.9.20'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does 
not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Microsoft.Build.Utilities.Core -Version 15.9.20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

如何解决此问题?

我正在使用VS 2017,但是原始项目是使用VS 2013编译的,有什么区别吗?

1 个答案:

答案 0 :(得分:0)

您需要安装.Net Framework 3.5(link),因为您需要“ Microsoft.Build.Utilities,Version = 2.0.0.0”。如果我没记错的话,它是崩溃到4.0版的依赖项之一