azure-devops - Azure DevOps dotnet build 找不到恢复的 nuget 包
问题描述
我在使用 Azure DevOps 时遇到了一个奇怪的问题,它dotnet restore
可以成功还原 nuget 包,但dotnet build
由于找不到包而失败。
这是我的管道中的步骤,以及每个步骤的一些输出
dotnet restore
在这一步中,我专门将 Destination 设置为packages
root 中的文件夹,以便我可以验证包是否实际存储。此外,由于我使用的是私有 nuget 存储库,因此我指定了 NuGet.config 文件和凭据。
ls && ls packages
我想确保软件包已恢复,因此我添加了此步骤。从输出中,我可以看到来自 nuget repo 和我的私人 repo 的包都在那里
dotnet build
我在这一步出错(并不总是。这一步偶尔会成功,有时在我更新一些管道配置之后)。在这一步中,错误说
The type or namespace name 'Migrations' does not exist in the namespace 'Microsoft.EntityFrameworkCore' (are you missing an assembly reference?)
对于这一步,我还尝试将 PowerShell 与命令一起使用dotnet build Booking.Server.csproj -c Release --no-restore --source ..\packages
,但我得到了同样的错误。
============================================
此外,我还检查了我的 csproj 文件,没有从本地路径引用任何包。
有人可以帮忙吗?
谢谢你。
============================================== 更新yaml文件
pool:
name: Azure Pipelines
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
feedsToUse: config
nugetConfigPath: Booking.Server/NuGet.config
externalFeedCredentials: 'GitLab Nuget Repository'
restoreDirectory: packages
verbosityRestore: Diagnostic
- powershell: |
ls
ls packages
ls packages/booking.shared
displayName: 'Check pakcages'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
projects: Booking.Server
arguments: '-c Release --no-restore --source ..\packages'
workingDirectory: Booking.Server
enabled: false
- powershell: |
ls
ls ..
ls ../packages
dotnet build Booking.Server.csproj -c Release --no-restore --source ..\packages --verbosity diag
workingDirectory: Booking.Server
displayName: Build
解决方案
此问题的可能原因是您的路径指向不正确的包文件夹,尤其是文件夹和子文件夹之间的混淆。你可以参考这个博客。
推荐阅读
- amazon-web-services - 能够在 Amazon CloudWatch Events 规则中指定唯一参数
- html - 如何使两个左浮动div不重叠?
- python - wxpython中三个面板网格布局中的嵌套sizer
- c# - Microsoft Cognitive Speech to Text - 不转换整个 .wav 文件
- javascript - 从数组向对象添加值,并且在数组用完时不会变为未定义
- excel - 如何在 VBA IE 自动化中相对单击复选框(通过提供来自 excel 单元格的数据)?
- matlab - 如何将 TF 训练的网络导出到 h5 文件
- python - PyQt5 QSlider 根据滑块移动的方向关闭一个
- mysql - 如何在 MySQL 中创建一个查看两个表的 Select 语句
- linux - 运行 vagrant up 时显示错误消息