The documentation here says
To publish to an external NuGet feed, you must first create a service connection to point to that feed....
It then provides this YAML:
- task: NuGetAuthenticate@0
inputs:
nuGetServiceConnections: '<Name of the NuGet service connection>'
- task: NuGetCommand@2
inputs:
command: push
nuGetFeedType: external
versioningScheme: byEnvVar
versionEnvVar: <VersionVariableName>
This fails with
"Error: The service connection for 'https://api.nuget.org/v3/index.json' is not valid. ApiKey service connections are not supported in this task. Instead, use -ApiKey (NuGet) or --api-key (dotnet) when invoking the tool itself. See the task documentation for more details."
I have created a service connection that points to nuget.org with my ApiKey.
I do not understand this portion of the error message: "Instead, use -ApiKey (NuGet) or --api-key (dotnet) when invoking the tool itself. See the task documentation for more details."
I have also seen this question which refers to a deficiency which has since been implemented.
Edit: Turns out the deficiency mentioned above is a red herring. The real problem is a limitation of nuget which still exists as of this writing.