【问题标题】:Azure Pipelines is not using the NuGet version specifiedAzure Pipelines 未使用指定的 NuGet 版本
【发布时间】:2019-02-26 18:37:12
【问题描述】:

这是我原来的 YML 文件。

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:

- task: NuGetToolInstaller@0
  displayName: "NuGet use 4.9.3"
  inputs:
    versionSpec: 4.9.3

- task: DotNetCoreInstaller@0
  inputs:
    version: '2.2.104'

- task: NuGetCommand@2
  displayName: "NuGet Restore"
  inputs:
    restoreSolution: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: ".NET build"
  inputs:
    projects: '**/*.csproj'
    arguments: --configuration $(BuildConfiguration) --no-restore

- task: DotNetCoreCLI@2
  displayName: ".NET publish package"
  inputs:
    command: publish
    arguments: '--configuration $(BuildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)/app/pkg'

这是我为 Nuget 还原步骤获得的输出。

[section]开始:NuGet 还原 ==================================================== ============================ 任务:NuGet 描述:恢复、打包或推送 NuGet 包,或运行 NuGet 命令。支持 NuGet.org 并经过身份验证 包管理和 MyGet 等提要。使用 NuGet.exe 并与 .NET 框架应用程序。对于 .NET Core 和 .NET Standard 应用,使用 .NET 核心任务。版本:2.147.6 作者:微软 公司帮助:More Information ==================================================== ============================ 缓存工具:NuGet 4.1.0 x64 在缓存中找到工具:NuGet 4.1.0 x64 从工具缓存中解决:4.1.0 使用版本:4.1.0 在中找到工具 缓存:NuGet 4.1.0 x64

如何禁用“工具缓存”?它使用的是 4.1.0 而不是 4.9.3。

更新:按照 cmets 的建议,我更新了我的 YML 文件。

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'

steps:

- task: DotNetCoreCLI@2
  inputs:
    command: restore

- task: DotNetCoreCLI@2
  displayName: ".NET build"
  inputs:
    projects: '**/*.csproj'
    arguments: --configuration $(BuildConfiguration) --no-restore

- task: DotNetCoreCLI@2
  displayName: ".NET publish package"
  inputs:
    command: publish
    arguments: '--configuration $(BuildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)/app/pkg'

我仍然遇到错误。

它仍然在做同样的事情。

开始 NuGet 恢复

任务:NuGet 描述:还原、打包或推送 NuGet 包,或运行 NuGet 命令。支持 NuGet.org 并经过身份验证 包管理和 MyGet 等提要。使用 NuGet.exe 并与 .NET 框架应用程序。对于 .NET Core 和 .NET Standard 应用,使用 .NET 核心任务。版本:2.147.6 作者:微软 公司帮助 : 更多 信息 h t t p s://go.microsoft.com/fwlink/?LinkID=613747

缓存工具:NuGet 4.1.0 x64 在缓存中找到工具:NuGet 4.1.0 x64 从工具缓存中解决:4.1.0 使用版本:4.1.0 在中找到工具 缓存:NuGet 4.1.0 x64 SYSTEMVSSCONNECTION 存在 true SYSTEMVSSCONNECTION 存在 true [命令]C:\windows\system32\chcp.com 65001 活动代码页:65001 检测到 NuGet 版本 4.1.0.2450 / 4.1.0 SYSTEMVSSCONNECTION 存在 true 将 NuGet.config 保存到临时配置文件。 [命令]C:\hostedtoolcache\windows\NuGet\4.1.0\x64\nuget.exe 源 添加 -NonInteractive -Name NuGetOrg -Source https://www.nuget.org/api/v2/-配置文件 d:\a\1\Nuget\tempNuGet_57.config 包源名称:NuGetOrg 添加成功。将 NuGet.config 保存到临时配置文件。

当它不再在我的 YML 文件中时,它为什么还要执行 Nuget 还原?

【问题讨论】:

  • 尝试将此noCache: true 添加到 NuGet 还原任务。
  • 如果它在 Ubuntu 上运行我会感到惊讶,因为任务描述:使用 NuGet.exe。如果这是 .NET Core 应用程序,请使用 dotnet restore
  • 不走运,它还在做同样的事情。
  • 我最终使用了 Microsoft Docs 示例中的 YML 文件并使用了 windows-2019。有效。 github.com/MicrosoftDocs/pipelines-dotnet-core/blob/master/…

标签: azure azure-devops nuget yaml azure-web-app-service


【解决方案1】:

这对我有用

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.9.x'
  inputs:
    versionSpec: 4.9.x

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Pipeline.TriggerDirectory)/Library.sln'
    vstsFeed: '[your feed here]'
    noCache: true

日志

工具安装

[部分]开始:使用 NuGet 4.9.x
==================================================== ======================== 任务:NuGet 工具安装程序
描述:从 Internet 或 工具缓存并将其添加到 PATH。使用此任务更改 NuGet 任务中使用的 NuGet 版本。
版本:0.145.0
作者 : 微软公司
求助:More Information
==================================================== ======================== 您正在对版本字符串使用查询匹配。随着 NuGet 更新到新版本,可能会发生行为更改或重大更改。 正在下载:https://dist.nuget.org/win-x86-commandline/v4.9.3/nuget.exe
缓存工具:NuGet 4.9.3 x64
使用版本:4.9.3
在缓存中找到工具:NuGet 4.9.3 x64
使用工具路径:C:\hostedtoolcache\windows\NuGet\4.9.3\x64 在 PATH 环境变量前添加目录:C:\hostedtoolcache\windows\NuGet\4.9.3\x64
[部分]整理:使用 NuGet 4.9.x

包恢复

[section]开始:NuGet 还原 ==================================================== ======================== 任务:NuGet
描述:还原、打包或推送 NuGet 包,或运行 NuGet 命令。支持 NuGet.org 和经过身份验证的源,如包管理和 MyGet。使用 NuGet.exe 并与 .NET Framework 应用程序一起使用。对于 .NET Core 和 .NET Standard 应用,请使用 .NET Core 任务。
版本:2.147.6
作者 : 微软公司
求助:More Information
==================================================== ======================== SYSTEMVSSCONNECTION 存在 true
SYSTEMVSSCONNECTION 存在 true
[命令]C:\windows\system32\chcp.com 65001
活动代码页:65001
检测到 NuGet 版本 4.9.3.5777 / 4.9.3+e5150f1e119e456e01c4f1e413213d392eda1c3a
SYSTEMVSSCONNECTION 存在 true
将 NuGet.config 保存到临时配置文件。
[命令]C:\hostedtoolcache\windows\NuGet\4.9.3\x64\nuget.exe

【讨论】:

【解决方案2】:

工具安装程序和 NuGet 任务更适合 Windows 机器。由于您使用的是 Ubuntu 代理,因此只需使用 dotnet restore 命令:

- task: DotNetCoreCLI@2
  inputs:
    command: restore

【讨论】:

  • 不走运。即使进行了更改,它仍然使用相同的 NuGet。
  • 它看我的 YML 吗?为什么我没有步骤时它仍在执行 NuGet 还原?
  • 我最终使用了 Microsoft Docs 示例中的 YML 文件并使用了 windows-2019。有效。 github.com/MicrosoftDocs/pipelines-dotnet-core/blob/master/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-03
  • 2021-01-08
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多