问题描述
我的 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:
And then I get compilation error like these:
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";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!