azure-devops - Azure Devops 服务管道构建失败。通过 Visual Studio 和 msbuild 命令提示符成功构建
问题描述
我有两个针对 .Net Framework 4 的项目的解决方案。该解决方案在 Visual Studio 2015 和 2017 以及 msbuild 命令行中成功构建。
但是,当它使用代理规范 vs2015-win2012r2 在 Azure DevOps Pipeline 中构建时,第一个项目失败并出现以下错误。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?)
我确实在包含 System.Web.Http.dll 的 csproj 文件中引用了 NuGet 包 Microsoft.Asp.Net.WebApi.Core.4.0.20710.0。
我已经打开了调试选项。以下是 NuGet 还原日志的链接https://drive.google.com/open?id=1lJWflXTjYTN_MQyLOnwMUr-8LKoR5JRo
和构建日志 https://drive.google.com/open?id=1ypAVWxniDLfBOBHc4gODdAoQOCQnphYg
解决方案
根据您的日志,有一条警告消息。
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 上构建时未找到。
推荐阅读
- spring - 如何修复'从'XXX'重定向到'YYY'已被cors策略阻止
- javascript - Vue.js 如何在渲染完成后使用 vue-router 创建自定义链接?
- r - 如何在 ggtree 的 `facet_plot` 中为构面添加图例?
- javascript - try / catch / finally 不是多余的吗?
- azure-devops - Azure devops 中的 Publish Artifact 任务在自动触发时失败,但在手动排队时通过
- laravel - 在 Laravel 中重用控制器/模型
- android - 如何在 Jetpack compose 中使用 EditText 或 TextInput 小部件?
- uefi - 更新 EFI 分区表缓存
- php - 如何在不使用内置函数的情况下在 php 中找到一个数组的缺失元素到另一个数组?
- webview - 在启动画面处于活动状态时,是否有办法加载 webview?