We have a warning in SonarQube that refers to the file encoding:
WARN: Encoding detected by Roslyn and encoding used by SonarQube do not match for file file://XXXX/XXXX/xxx.cs. SonarQube encoding is 'windows-1252', Roslyn encoding is 'UTF-8'. File will be skipped.
WARN: Invalid character encountered in file/XXXX/XXXX/xxx.cs at line 169 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
How do we change the encoding in SonarQube to UTF-8?
SonarQube 9.2 is being used.
In Gitlab-ci.yml,we are using below code.
script:
- "apt-get update"
- "apt-get install --yes openjdk-11-jre"
- "dotnet tool install --global dotnet-sonarscanner"
- "export PATH=\"$PATH:$HOME/.dotnet/tools\""
- "dotnet sonarscanner begin /k:\"platoon\" /d:sonar.sourceEncoding=UTF-8 /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
- "dotnet build"
- "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
How to resolve this issue?