Request for solution to rename a C# project, without changing the project key, for

  • ALM used - Azure devops

  • CI system used Azure DevOps

  • Scanner command used dotnet sonarscanner

  • Languages of the repository - C#

Steps to reproduce

Created sonar cloud c# project in using devops to run the below command

dotnet sonarscanner begin
/o:“$SONAR_OGRANIZAION” \ etc etc command

Project is created with SONAR_PROJECT_KEY parameter value name

But when I try to rename the sonarcloud project in with below syntax , did not rename previously created project name with SONAR_PROJECT_NAME parameter value. Could you please help
dotnet sonarscanner begin


Welcome to the community!

Could you expand on what you mean when you say “override”? And also, can you provide detail on what did/didn’t happen when you did that?


Trying to rename existing project name with SONAR_PROJECT_NAME parameter value but existing project name is not renamed to the value of SONAR_PROJECT_NAME parameter


Can you check the scanner context (Administration → Background Tasks → [row dots menu] → Show SonarScanner Context) to see what sonar.projectName value was included in the analysis?


Hi Ann,

I am not able to see background tasks - could you please let me know I am missing some thing


Look at the project level:


project name I am expecting is swo-digital-common but found softwareone-pc_swo-digital-common value. This value is actual sonar project key value which I am not expecting to be here


So it looks like a problem setting your variable. That’s going to be somewhere in your pipeline before analysis.

Alternately, it’s possible that analysis is automatically defaulting the project name to the value of sonar.projectKey because no sonar.projectName is provided. And that would also be about the values that get set up before / go into analysis.


Hi Ann. I have used correct project name and able to see correct project name in sonarscanner context in below screenshot

But while searching for the project name swo-digital-common - I am not able to see the entry with swo-digital-common only instead found with project key - not correct - expected should be swo-digital-common should be be found instead of project key mentioned in below screenshot


I’d like to double check your analysis logs. Can you:

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
  • The important logs are in the END step (i.e. SonarCloudAnalyze / “Run Code Analysis”)

And share the logs here, redacted as necessary, please?



Thanks for the screenshots. I’d much prefer the full text copy/pasted here.


here are the logs

logs.txt (222.8 KB)

1 Like


Thanks for the logs. They make it quite clear that the new project name was correctly set:

2023-06-28T13:52:04.9270443Z 13:52:04.926  Dumping content of
2023-06-28T13:52:04.9270947Z ------------------------------------------------------------------------
2023-06-28T13:52:04.9271515Z sonar.projectKey=softwareone-pc_swo-digital-common
2023-06-28T13:52:04.9271911Z sonar.projectName=swo-digital-common
2023-06-28T13:52:04.9272481Z sonar.projectBaseDir=/app/src
2023-06-28T13:52:04.9272701Z sonar.pullrequest.cache.basepath=/app

And… sometimes the SonarScanner for .NET works differently than I expected it to. So I’m going to flag this for specialist eyes.


1 Like

Hi Anna,

Hope you had great week end.

Did you get chance to look into this as this is blocking us

Thank you

Hello @suresh.kothapalli

First of all, I am sorry for the late reply!

From the logs, I can see that you are doing the analysis on a branch, and that is the reason why the renaming did not work. You have to do an analysis against your main branch to be able to rename the project.

All the best,


Hi Caba,

I was on vacation. Apologies for the late reply. Could you please let me know the reasons why renaming does not work on other branch than on main branch ?

Thanks for your help

Suresh Kothapalli

Hi Suresh,

You can probably chalk this up to the underlying architecture. The main branch is the project. Under the covers, everything else is just an appendage.