The format of the analysis property sonar.token= is invalid

Hi,

I’m using SonarScanner for MSBuild 9.0 and encountering the following error during the analysis:

SonarScanner for MSBuild 9.0

Using the .NET Core version of the Scanner for MSBuild

Default properties file was found at /root/.dotnet/tools/.store/dotnet-sonarscanner/9.0.0/dotnet-sonarscanner/9.0.0/tools/netcoreapp3.1/any/SonarQube.Analysis.xml

Loading analysis properties from /root/.dotnet/tools/.store/dotnet-sonarscanner/9.0.0/dotnet-sonarscanner/9.0.0/tools/netcoreapp3.1/any/SonarQube.Analysis.xml

The format of the analysis property sonar.token= is invalid

The token is correctly defined, and this error wasn’t showing up before. How can I resolve this issue?

sonarqube-check:
  stage: sonarqube-check
  image: mcr.microsoft.com/dotnet/sdk:8.0
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
    GIT_DEPTH: "0"
    SONAR_HOST_URL: "https://my-domain.com"
  cache:
    policy: pull
    key: "${CI_COMMIT_SHORT_SHA}"
    paths:
      - .sonar/cache
  before_script:
    - cp ${CI_PROJECT_DIR}/certs/truststore.p12 /usr/local/share/ca-certificates/truststore.p12
    - update-ca-certificates
  script: 
      - "apt-get update"
      - "apt-get install --yes --no-install-recommends openjdk-17-jre"
      - "dotnet tool install --global dotnet-sonarscanner"
      - "export PATH=\"$PATH:$HOME/.dotnet/tools\""
      - "dotnet-sonarscanner begin /k:\"my-token\" /d:sonar.scanner.skipJreProvisioning=true /d:sonar.projectBaseDir=\"${CI_PROJECT_DIR}\" /d:sonar.token=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
      - "dotnet build"
      - "dotnet sonarscanner end /d:sonar.token=\"${SONAR_TOKEN}\""
  allow_failure: true

Hi @Marcos_Vinicius

It might just be a typo when copying your pipeline here, but it looks like you are missing the braces {} around SONAR_TOKEN in the begin step:

in the being step: /d:sonar.token=\"$SONAR_TOKEN\"
in the end step: /d:sonar.token=\"${SONAR_TOKEN}\"

Denis