AzureDevops Task name NuGetCommand is ambiguous

Viewed 597

I am getting the following error when trying to run my pipeline

Job Job: Step  task reference is invalid. The task name NuGetCommand is ambiguous. 
Specify one of the following identifiers to resolve the ambiguity: 
.NuGetCommand, .NuGetCommand

Below is my .yml file for my .Net Standard library

trigger:
- main

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/MyLibrary.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/MyLibrary.sln'
    feedsToUse: 'config'
    nugetConfigPath: './nuget.config'

- task: VSBuild@1
  inputs:
    solution: '**\MyLibrary.sln'
    vsVersion: '15.0'
    restoreNugetPackages: true

It seems to be complaining about NugetCommand@2 which doesn't make sense when it comes built in?

Edit Have also tried using - task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2 instead of - task: NuGetCommand@2

2 Answers

One may have been pushed straight into the account using tfx build tasks upload, run tfx build tasks list to find out which ones are installed and if needed delete the non-official one using tfx build tasks delete.

C:\Users\jesse>npm install tfx-cli -g
C:\Users\jesse>tfx build tasks list
TFS Cross Platform Command Line Interface v0.8.3
Copyright Microsoft Corporation
> Service URL: https://dev.azure.com/jessehouwing-dev
> Personal access token:

The one you want to keep is:

id            : 333b11bd-d341-40d9-afcf-b32d5ce6f23b
name          : NuGetCommand
friendly name : NuGet
visibility    :
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.179.0

If there is one with a different guid, delete is with:


C:\Users\jesse>tfx build tasks delete --task-id the-task-id-guid-to-delete

It may also have been pushed as part of a privately shared custom extension. The marketplace will block tasks with the rame GUID, but it will allow installing a task with the same name just fine through an extension. Check your installed extensions, especially privately shared ones.

AzureDevops Task name NuGetCommand is ambiguous

According to the error message, it seems that error can happen when two tasks\extensions exist in your Azure DevOps organization with the same name.

You could use this REST API:

https://dev.azure.com/{organisationName}/_apis/distributedtask/tasks?visibility%5B%5D=Build

to check here for possible duplicates.

To resolve this issue, you could use command line to invoke nuget.exe to restore the solution:

nuget.exe restore a.sln -source "xx" -PackagesDirectory
Related