【问题标题】:Azure Pipelines failing at NuGet Restore stageAzure Pipelines 在 NuGet 还原阶段失败
【发布时间】:2021-06-25 09:08:54
【问题描述】:

我正在使用 Image vs2017-win2016 进行构建,作为构建的一部分,我有 Nuget 还原任务,该任务失败并显示以下错误消息。有人可以告诉我这里出了什么问题以及我们如何解决它吗?这是一个简单的 Asp.Net Web 应用程序。

2021-06-25T09:01:16.6036745Z ##[section]Starting: NuGet restore
2021-06-25T09:01:16.6136450Z ==============================================================================
2021-06-25T09:01:16.6136733Z Task         : NuGet
2021-06-25T09:01:16.6137224Z Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
2021-06-25T09:01:16.6137701Z Version      : 2.179.0
2021-06-25T09:01:16.6138100Z Author       : Microsoft Corporation
2021-06-25T09:01:16.6138522Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/nuget
2021-06-25T09:01:16.6138831Z ==============================================================================
2021-06-25T09:01:17.3136968Z SYSTEMVSSCONNECTION exists true
2021-06-25T09:01:17.4377830Z SYSTEMVSSCONNECTION exists true
2021-06-25T09:01:17.8046121Z [command]C:\Windows\system32\chcp.com 65001
2021-06-25T09:01:17.8104107Z Active code page: 65001
2021-06-25T09:01:17.8631847Z Detected NuGet version 4.4.1.4656 / 4.4.1
2021-06-25T09:01:17.8642220Z SYSTEMVSSCONNECTION exists true
2021-06-25T09:01:17.8812714Z [command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_31.config
2021-06-25T09:01:19.1590360Z Package Source with Name: NuGetOrg added successfully.
2021-06-25T09:01:19.1660433Z [command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\VSDemoPipeline.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_31.config
2021-06-25T09:01:47.4269841Z C:\Program Files\dotnet\sdk\2.1.524\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [D:\a\1\s\VSDemoPipeline\VSDemoPipeline.csproj]
2021-06-25T09:01:47.4271151Z 
2021-06-25T09:01:47.4279527Z NuGet Version: 4.4.1.4656
2021-06-25T09:01:47.4280682Z MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
2021-06-25T09:01:47.4281803Z MSBuild P2P timeout [ms]: 120000
2021-06-25T09:01:47.4283437Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\4rucjvrx.krk.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\opqnszhe.dir.nugetrestore.targets" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s" /p:RestoreConfigFile="D:\a\1\Nuget\tempNuGet_31.config" /p:SolutionDir="D:\a\1\s"
2021-06-25T09:01:47.4289820Z NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
2021-06-25T09:01:47.4334578Z    at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
2021-06-25T09:01:47.4335343Z --- End of stack trace from previous location where exception was thrown ---
2021-06-25T09:01:47.4335807Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-06-25T09:01:47.4336289Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-06-25T09:01:47.4336788Z    at NuGet.CommandLine.RestoreCommand.<GetDependencyGraphSpecAsync>d__48.MoveNext()
2021-06-25T09:01:47.4337172Z --- End of stack trace from previous location where exception was thrown ---
2021-06-25T09:01:47.4337555Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-06-25T09:01:47.4337950Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-06-25T09:01:47.4339708Z    at NuGet.CommandLine.RestoreCommand.<DetermineInputsFromMSBuildAsync>d__43.MoveNext()
2021-06-25T09:01:47.4855912Z ##[error]The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\2.1.524\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [D:\a\1\s\VSDemoPipeline\VSDemoPipeline.csproj])
2021-06-25T09:01:47.4866755Z ##[error]Packages failed to restore
2021-06-25T09:01:47.4877131Z ##[section]Finishing: NuGet restore

【问题讨论】:

    标签: azure-devops nuget azure-pipelines


    【解决方案1】:

    要在 NET Core 3.1 或更高版本上构建 APS.NET 应用,请在 Azure DevOps 中使用 windows-latest 代理。

    旧版本的代理不支持它,如果您注意到错误也很明显。

    nuget 命令失败,退出代码 (1) 和错误 (C:\Program Files\dotnet\sdk\2.1.524\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137, 5):错误NETSDK1045:当前.NET SDK不支持面向.NET Core 3.1。要么面向.NET Core 2.1或更低版本,要么使用支持.NET Core 3.1的.NET SDK版本。[D:\a \1\s\VSDemoPipeline\VSDemoPipeline.csproj]) 2021-06-25T09:01:47.4866755Z ##[错误]包无法恢复

    在管道中,确保您具有适当版本的“使用 Dotnet Core”任务:

    【讨论】:

    • 感谢您的更新。我正在使用经典管道和代理规范下我没有找到“Windows-latest”,我只找到了 windows-2019 但它也不起作用。知道为什么我在代理规范下看不到 windows-latest 吗?
    • 是的,经典管道似乎有 windows-2019。在您的管道中,您是否添加了正确填写版本的“使用 .NET 核心”任务?
    猜你喜欢
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    相关资源
    最近更新 更多