【发布时间】:2017-12-31 18:42:50
【问题描述】:
我在一堆 .NET Framework 项目的解决方案中构建一个 ASP.NET Core 项目(目标框架为 .NET Framework 4.5.2)。我正在引用使用StyleCop.MsBuild 的项目之一。但是,当我执行dotnet build 时,我得到:
C:\MySolution\nupkgs\StyleCop.MSBuild.4.7.54.0\build\StyleCop.MSBuild.Targets(101,5): error MSB4062: The "StyleCopTask" task could not be loaded from the assembly
C:\MySolution\nupkgs\StyleCop.MSBuild.4.7.54.0\build\..\tools\StyleCop.dll. Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. 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. [
C:\MySolution\src\MyProject\MyProject.csproj]
MyProject 是我要引用的项目。
我尝试将System.Windows.Forms 包含为依赖项,但它的版本是 4.0.0.0 而不是 2.0.0.0,所以这似乎不起作用。
有没有参考System.Windows.Forms 来构建它?
【问题讨论】:
-
AFAICT 正确的解决方案是升级
StyleCop.MsBuild以支持现代版本的 .Net Framework / Core。
标签: asp.net-core stylecop