microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.45k stars 2.6k forks source link

[BUG]: NuGetCommand@2 throws warning NoCache is deprecated #20146

Closed Nico-1987 closed 1 month ago

Nico-1987 commented 1 month ago

New issue checklist

Task name

NuGetCommand

Task version

2

Issue Description

After upgrading to NuGet 6.10, the NuGetCommand task is throwing a warning when using argument NoCache:true

This argument has been renamed in NuGet, so this is by design, however i currently have no way to suppress this warning in my Azure DevOps pipelines. Please enhance the task to pass the new NoHttpCache argument instead (when version > 6.10 is used)

Here is a sample

- task: NuGetToolInstaller@1
  displayName: Install Latest NuGet Installer
  inputs:
    versionSpec: 6.10.*

- task: NuGetCommand@2
  displayName: Restore NuGet Packages
  inputs:
    command: restore
    restoreSolution: ${{ parameters.Solution }}
    noCache: true

This will result in this warning in the output

"NoCache is deprecated and has been renamed to NoHttpCache. Please use NoHttpCache instead."

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

Azure DevOps Server 2022 Update 1

Operation system

Windows 10

Relevant log output

Starting: Restore NuGet Packages
==============================================================================
Task         : NuGet
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.
Version      : 2.222.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/nuget
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 6.10.0.107 / 6.10.0+6970ffe10efff51d43862ea8f8a2ef0170250262.6970ffe10efff51d43862ea8f8a2ef0170250262
C:\Agents\AG3\_work\_tool\NuGet\6.10.0\x64\nuget.exe restore C:\Agents\AG3\_work\3659\s\Sources\SolutionFile.sln -NoCache -Verbosity normal -NonInteractive
NoCache is deprecated and has been renamed to NoHttpCache. Please use NoHttpCache instead.
MSBuild auto-detection: using msbuild version '17.10.4.21802' from 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\bin'.

Full task logs with system.debug enabled

na

Repro steps

- task: NuGetToolInstaller@1
  displayName: Install Latest NuGet Installer
  inputs:
    versionSpec: 6.10.*

- task: NuGetCommand@2
  displayName: Restore NuGet Packages
  inputs:
    command: restore
    restoreSolution: ${{ parameters.Solution }}
    noCache: true
Nico-1987 commented 1 month ago

Related change: https://github.com/NuGet/Home/issues/9180

jmyersmsft commented 1 month ago

The NuGetCommand task is soft-deprecated and only takes critical fixes.

Instead, we recommend using the NuGetAuthenticate@1 task followed by another task which runs NuGet, for example:

- task: NuGetToolInstaller@1
  displayName: Install Latest NuGet Installer
  inputs:
    versionSpec: 6.10.*

- task: NuGetAuthenticate@1

- powershell: nuget restore ${{ parameters.Solution }} -NoHttpCache