简体   繁体   English

Nuget 使用 .NET Core SDK 5.0.100 恢复失败

[英]Nuget restore fails with .NET Core SDK 5.0.100

I just updated a solution to use net50 , and it builds locally, but does not build in an Azure pipeline.我刚刚更新了一个使用net50的解决方案,它在本地构建,但不在 Azure 管道中构建。 How do I specify an Azure pipeline agent capable of building net50 projects?如何指定能够构建net50项目的 Azure 管道代理?


The pipeline fails on the nuget restore step with the following error:管道在nuget restore步骤失败并出现以下错误:

The nuget command failed with exit code(1) and error([***].csproj : error : 
Version 5.0.100 of the .NET Core SDK requires at least version 16.8.0 of MSBuild. 
The current available version of MSBuild is 16.7.0.37604. 
Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.

My pipeline yaml includes:我的管道 yaml 包括:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Debug'

steps:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 5.x
    installationPath: $(Agent.ToolsDirectory)/dotnet

- task: NuGetCommand@2
  displayName: 'nuget restore'
  inputs:
    restoreSolution: '**/*.sln'
    feedsToUse: config
    nugetConfigPath: 'NuGet.config'

A workaround to using the NuGetCommand@2 step is to use the DotNetCoreCLI@2 step instead.使用NuGetCommand@2步骤的解决方法是改用DotNetCoreCLI@2步骤。 This may not be viable if you are building legacy (non-SDK) projects.如果您正在构建遗留(非 SDK)项目,这可能不可行。

My YAML is now:我的 YAML 现在是:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Debug'

steps:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 5.x
    installationPath: $(Agent.ToolsDirectory)/dotnet

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'

Thanks to @Krzysztof for pointing me in the right direction.感谢@Krzysztof 为我指明了正确的方向。

FWIW, and this is from memory, using DotNetCoreCLI@2 for a net48 project - which happened to be included in this pipeline's solution - failed under netcoreapp3.1 , but appears to work under net50 . FWIW,这是来自 memory,将DotNetCoreCLI@2用于net48项目 - 恰好包含在此管道的解决方案中 - 在netcoreapp3.1下失败,但似乎在net50下工作。

It looks that images haven't been updated yet and 16.8 is not available.看起来图像还没有更新,16.8 不可用。 Please check this GitHub issue :请检查此GitHub 问题

We keep the visual studio version always up to date.我们始终保持 visual studio 版本是最新的。 However, deploying images can sometimes take a week(or two).但是,部署图像有时可能需要一周(或两周)。

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

相关问题 NuGet恢复后,MSBuild在单元测试项目(.NET Core)上失败 - MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore 从NuGet恢复步骤中排除.NET Standard / .NET Core项目 - Exclude .NET Standard/.NET Core projects from NuGet restore step .net 核心 3.1 Azure devops 管道在 nuget 恢复时失败 - .net core 3.1 Azure devops Pipeline failed on nuget restore 在VSTS中构建时,asp .net core restore命令失败 - asp .net core restore command fails when building in VSTS Visual Studio Online:Nuget包还原失败 - Visual Studio Online: Nuget Package restore fails 在Nuget Restore步骤中VSTS构建失败 - VSTS Build Fails in the Nuget Restore step 新的.net核心视觉工作室2017项目nuget恢复CI构建定义 - new .net core visual studio 2017 project nuget restore in CI build definition 将所有项目升级到 .Net core 2.2 后,Azure DevOps 上的 Nuget 恢复任务失败 - Nuget restore task is failing on Azure DevOps after upgrading all projects to .Net core 2.2 Azure Devops Build pipeline NuGet 包失败(.net core 5) - Azure Devops Build pipeline NuGet pack fails (.net core 5) Dot.net 测试无法在 Azure DevOps 中恢复 EnterpriseLibrary.Logging Nuget - Dot net test fails to restore EnterpriseLibrary.Logging Nuget in Azure DevOps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM