【问题标题】:Nuget restore task is failing on Azure DevOps after upgrading all projects to .Net core 2.2将所有项目升级到 .Net core 2.2 后,Azure DevOps 上的 Nuget 还原任务失败
【发布时间】:2019-05-19 00:49:17
【问题描述】:

我们已将所有项目从 .net core 2.1 升级到 .Net core 2.2,在升级之前,所有项目都在 azure devops 管道上成功构建,但在升级到 .net core 2.2 后,Nuget 还原任务失败并出现以下错误

018-12-17T22:20:06.8107786Z ##[error]The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\2.1.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.

我已经更新了对所有项目的 .net core 2.2 引用,我们没有使用项目中的 nuget.exe。

我错过了什么?

更新 1

根据 rick 的回复,我在管道中添加了 .net 核心任务,但仍然失败

【问题讨论】:

    标签: msbuild nuget azure-devops tfsbuild nuget-package-restore


    【解决方案1】:

    尝试运行 dotnet restore 而不是使用 nuget 任务。

    您可以在此处找到更多文档:Build, test, and deploy .NET Core apps in Azure Pipelines - Restore dependencies

    NuGet 是一种依赖非构建代码的流行方式。您可以通过.NET Core 任务或直接在管道中的脚本中运行dotnet restore 命令来下载 NuGet 包。

    编辑:
    看看你正在使用的 NuGet 包,因为你收到的消息试图告诉你一些事情:
    The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2
    您的所有项目都针对相同的版本吗?

    【讨论】:

    • 嗨 Rick,我尝试添加 .net 核心任务并运行构建,但仍然失败
    • @ankitpatel 您在使用dotnet restore 时遇到了什么错误?请提供更多相关信息。
    • 使用屏幕截图更新问题 - 2018-12-18T15:12:27.2196719Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1 2018-12 -18T15:12:27.2223476Z ##[error]包恢复失败
    • 如何在管道中使用命令 dotnet restore ?还是会是 power shell 脚本?我不确定 YAML 配置
    • @ankitpatel 查看my answer中的Restore dependencies链接
    【解决方案2】:

    在尝试了不同的解决方案后,我遇到了 scott hanselman 的博客,其中谈到了关于 asp.net core 2.2 预览版的 Azure Devops CI,但博客谈到了相同的错误,并且通过添加解决了相同的问题.NET Core SDK 安装程序任务。

    https://www.hanselman.com/blog/AzureDevOpsContinuousBuildDeployTestWithASPNETCore22PreviewInOneHour.aspx

    通过添加 2.2.10 版本的 .NET Core SDK 安装程序任务解决了我的问题。

    【讨论】:

      【解决方案3】:

      我在使用经典管道时遇到了类似的问题。当我在 .NET 还原步骤中遇到以下错误时,我正在将 Web 应用程序更新到 .NET Core 3.1。

      [错误] nuget 命令失败,退出代码 (1) 和错误(C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets (137,5):错误 NETSDK1045:当前的 .NET SDK 不支持面向 .NET Core 3.1。要么面向 .NET Core 2.2 或更低版本,要么使用支持 .NET Core 3.1 的 .NET SDK 版本。

      我能够通过将我的代理池更改为更新的代理池(2019 年)来解决这个问题,如下所示,而不是开始时无法处理较新的 SDK 的代理池(2017 年)。

      【讨论】:

        猜你喜欢
        • 2020-10-18
        • 2020-09-28
        • 1970-01-01
        • 1970-01-01
        • 2021-08-09
        • 2020-09-14
        • 2020-05-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多