Can't replace SonarCloud v1 CLI tasks with v2 (Azure DevOps)

Note: Replace all “v1/v2” with “@ 1 and @ 2”, won’t let me post thread as it thinks I’m mentioning users.

v1 tasks are deprecated and being dropped in the next release of SonarCloud. I’m trying to replace everything, but I keep getting:

##[error]ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties,
the 'SONAR_TOKEN' environment variable, or contact the project administrator to check the permissions of the user the token belongs to

Now, this is strange, as my v1 tasks work perfectly normal. This is what it looks like, for example:

- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPreparev1
  condition: succeeded()
  displayName: "Prepare analysis on SonarCloud"
  inputs:
    SonarCloud: "SonarCloud - Analysis"
    organization: "x-apps"
    scannerMode: CLI
    configMode: manual
    cliProjectKey: "x"
    cliProjectName: "x"
    extraProperties: |
	 xxx

This works just fine, but when I try to replace the entire task name with: SonarCloudPreparev2, it tells me I’m missing all those values and credentials that are already in place, since v1 is working.

I do believe this is related to the huge name of the v1 task, but I can’t figure out why is it like that, nor I can find an example of that online. Any help appreciated, thanks.

Hey there.

I can’t reproduce this on my side.

What I think you’re doing right now is just changing the version number.

If you generate the task YAML from the UI (selecting the service connection, filling out the form) and use the output, do you still face the issue?

For good measure, make sure you also update the SonarCloudAnalyze task.