Azure devops Azure Devops服务管道构建失败。通过Visual Studio和msbuild命令提示符成功生成

Azure devops Azure Devops服务管道构建失败。通过Visual Studio和msbuild命令提示符成功生成,azure-devops,Azure Devops,我有两个项目的解决方案,都是针对.Net Framework 4的。该解决方案在Visual Studio 2015和2017以及msbuild命令行中成功构建 但是,当它使用代理规范vs2015-win2012r2在Azure DevOps管道中构建时,第一个项目失败,出现以下错误。NuGet还原步骤显示它已成功安装NuGet EntityFramework 5.0包 The type or namespace name 'Infrastructure' does not exist in t

我有两个项目的解决方案,都是针对.Net Framework 4的。该解决方案在Visual Studio 2015和2017以及msbuild命令行中成功构建

但是,当它使用代理规范vs2015-win2012r2在Azure DevOps管道中构建时,第一个项目失败,出现以下错误。NuGet还原步骤显示它已成功安装NuGet EntityFramework 5.0包

The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
当我将代理规范更改为vs2017-win2016时,第一个项目生成时没有错误,但第二个项目失败,出现以下错误:

The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
我确实在csproj文件中引用了NuGet包Microsoft.Asp.Net.WebApi.Core.4.0.20710.0,该文件包含System.Web.Http.dll


我已经打开了调试选项。以下是指向NuGet还原日志的链接

以及构建日志

根据您的日志,有一条警告消息

warning MSB3267: The primary reference "System.Net.Http", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Net.Http" or retarget your application to a framework version which contains "System.Net.Http". 
在本地计算机上执行命令时,以及在代理上运行生成或发布时,存在一些差异。如果将代理配置为在Linux、macOS或Windows上作为服务运行,则它不会在交互式登录会话中运行。如果没有交互式登录会话,则存在UI交互和其他限制。还有一些是微软提供的


有一种简单的方法可以尝试解决此错误。删除项目引用下的引用,然后将其重新添加。该引用是对解决方案的本地项目中的命名空间的引用。由于某些原因,它在本地找到,但在签入VSTS并在VSTS上构建时未找到。

请使用变量system.debug=true再次运行管道,然后在此处共享nuget还原日志和错误生成日志?@Linda K您尝试过下面的解决方案了吗,有什么好消息吗?没有,我没有尝试下面的解决方案。我通过使用自托管代理解决了这个问题。