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"

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

问题描述

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

<块引用><块引用>

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

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

<块引用><块引用>

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

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

等 ILoggerFactory、SqlDataReader 等.一切都在我的本地机器上完美构建.我错过了什么?

解决方案

  • 首先请确保 .csproj 中的 PackageReference 没有引用本地路径.它应该是:

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

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

    使用 .NET Core 任务进行恢复、构建、测试和发布,您还可以根据需要添加其他任务.

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

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:

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

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

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

解决方案

  • 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" />
    

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

    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天全站免登陆