C# build-wrapper analysis is published on to the wrong branch

Did a C# build with build-wrapper on a feature branch on Azure DevOps.
The result is published to the main brain. This is wrong, the result should be published on to the feature branch and not to the main. Strange what can we do to not corrupt the main branch by a feature build analysis.
Is there a parameter to give to tell the branch where the build is running?
This one does not have any effect: /d:sonar.branch.name=“$(branchname)”

The task here:

  - task: CmdLine@2
    displayName: 'SonarCloud C# Build with build-wrapper'
    condition: and(succeeded(), eq('${{ parameters.LaunchSonarCSharpBuildWrapper}}', true))
      script: |
        dotnet sonarscanner begin /k:"PROJ_SonarWrapper" /o:"proj-sonarcloud-wrapper" /d:sonar.login="$(TOKEN)" /d:sonar.host.url="https://sonarcloud.io"
        /d:sonar.dotnet.excludeTestProjects=true  /d:sonar.branch.name="$(branchname)"
        dotnet build "$(Build.SourcesDirectory)\sonarqube-scanner-msbuild\CSharpProject\SomeConsoleApplication.sln"
        dotnet sonarscanner end /d:sonar.login="$(EXAMPLE-TOKEN)"

Hey there

Unless it’s a copy paste issue, it looks like these are on separate lines (dotnet sonarscanner begin and /d:sonar.login....), which means they aren’t actually appended to the first line.

And – are you sure you need the build wrapper? It isn’t required for C# code, only for projects that contain C/C++ code.

Thank’s Colin,
Good point, it was a on a separate line in the yaml. error in yaml scalar type usage.
we have to use -script: > instead of script: |

We are not sure if we need a build wrapper. We use it as the C# build is called from a buildall.cmd shell script and not from an AzureDevOps build task. We do not know if we can use the -task: SonarCloudPrepare@1 to have the build scripts being analyzed from a - task: CmdLine@2 that’s why we plan to use a build wrapper. And as we did not find a way to let SonarCloud to manage C#/Cpp mixed project then the solution could be to use build wrapper for C# mixed with Cpp build wrapper.

Analyzing any C/C++ code will require the build wrapper. If you’re just analyzing C# code, it’s not necessary.