VSTS-构建ASP.NET Core 2.0,编译错误:无法找到程序集"Microsoft.AspNetCore.Mvc.ViewFeatures"; [英] VSTS - Building ASP.NET Core 2.0, compile error: Could not locate the assembly "Microsoft.AspNetCore.Mvc.ViewFeatures"

查看:361
本文介绍了VSTS-构建ASP.NET Core 2.0,编译错误:无法找到程序集"Microsoft.AspNetCore.Mvc.ViewFeatures";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET Core 2.0 MVC应用程序的VSTS构建因以下警告而失败:

VSTS build of my ASP.NET Core 2.0 MVC app fails with these warnings:

警告MSB3245:无法解决此引用.无法找到程序集"Microsoft.AspNetCore.Mvc.ViewFeatures". 警告MSB3245:无法解析此引用.无法找到程序集"Microsoft.Extensions.Logging.Abstractions".检查以确保程序集在磁盘上.如果您的代码需要此引用,则可能会出现编译错误. 警告MSB3245:无法解析此引用.无法找到程序集"System.Data.SqlClient".检查以确保程序集在磁盘上.如果您的代码需要此引用,则可能会出现编译错误.

Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Mvc.ViewFeatures". Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Logging.Abstractions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. Warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Data.SqlClient". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

然后我得到如下编译错误:

And then I get compilation error like these:

名称空间"Microsoft"中不存在类型或名称空间名称扩展名"(您是否缺少程序集引用?)

The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

错误CS0246:找不到类型或名称空间名称'ILogger'(您是否缺少using指令或程序集引用?)

Error CS0246: The type or namespace name 'ILogger' could not be found (are you missing a using directive or an assembly reference?)

等等,例如ILoggerFactory,SqlDataReader等.一切都在本地计算机上完美构建.我想念什么?

and so on for ILoggerFactory, SqlDataReader, etc. And everything builds perfectly on my machine locally. What am I missing?

推荐答案

  • 首先,请确保.csproj中的 PackageReference 未引用本地路径.它应该像:

    • First please make sure the PackageReference in .csproj are not refer the local paths. It should like:

      <ItemGroup>
      <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
      <PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.0" />
      <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
      <PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
      

      然后请使用 ASP.Net Core模板定义您的构建定义:

      Then please use ASP.Net Core template to define your build definition:

      通过.NET Core任务可以还原,构建,测试和发布,还可以根据需要添加其他任务.

      With the .NET Core tasks to restore, build, test and publish, and you can also add other tasks for your needs.

      这篇关于VSTS-构建ASP.NET Core 2.0,编译错误:无法找到程序集"Microsoft.AspNetCore.Mvc.ViewFeatures";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆