代码之家  ›  专栏  ›  技术社区  ›  mans

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

  •  0
  • mans  · 技术社区  · 7 年前

    我有一个WPF应用程序,大约一年没有接触过,现在我有了一台新电脑。

    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 回复  |  直到 7 年前
        1
  •  1
  •   Kaspar    7 年前

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