繁体   English   中英

NuGet 还原任务失败(与 netcoreapp2.2 不兼容),但在 Visual Studio 中有效

[英]NuGet Restore task fails (not compatible with netcoreapp2.2), but it works in Visual Studio

我正在尝试在 Azure 管道中构建一个存储库。 它在 Visual Studio 中构建正常,但是当使用 Azure 管道(在构建机器上运行代理)时,它失败并出现以下错误:

The nuget command failed with exit code(1) and error

Project MyProject is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). 
Project MyProject supports: netstandard2.0 (.NETStandard,Version=v2.0)

我怎样才能解决这个问题?

这是 yaml 构建脚本:

pool:
  name: MyBuildServer
  demands:
  - msbuild
  - visualstudio

steps:
- task: NuGetCommand@2
  displayName: 'NuGet restore'

- task: VSBuild@1
  displayName: 'Build solution **\*.sln'

- task: VSTest@2
  displayName: 'Run tests'
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'

NuGet 还原任务失败(与 netcoreapp2.2 不兼容),但在 Visual Studio 中有效

Azure管道上使用的nuget的版本似乎不是最新版本,这可能会导致不兼容问题。

要解决此问题,您可以尝试添加 NuGet Tool Installer 任务,将其指向要安装的NuGet.exe版本,您只需指定要在 build 中执行的所需NuGet.exe的版本号。

在此处输入图像描述

正确配置后,使用最新版本的 .net 内核构建全部成功。

此外,如果以上没有解决您的问题,您可以尝试使用 dotnet restore 任务而不是 nuget 恢复任务。

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM