簡體   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