1:sonar version, Community Build v25.2.0.
2:adding configuration for sonar .net code coverage, which is being passed through Jenkins free-style project,
REM Set Environment Variables
set SONAR_HOST_URL=http://190.168.8.122:9000
set SONAR_LOGIN=sqp_6xxxxx0xxxxxxxxxx
set PROJECT_DIR=C:\_Demo2\repository\demo_Internal\demo_API
set COVERAGE_FILE=%PROJECT_DIR%\XUnitTest\coverage.xml
echo BUILD_NUMBER is %BUILD_NUMBER%
set BUILD_NUMBER=%BUILD_NUMBER%
REM Navigate to project directory
cd /d %PROJECT_DIR%
REM Checkout the cni_sonarqube branch
git checkout cni_sonarqube
git fetch
git pull
REM Run Code Coverage with Coverlet
coverlet "%PROJECT_DIR%\XUnitTest\bin\Debug\net6.0\XUnitTest.dll" ^
--target "dotnet" ^
--targetargs "test %PROJECT_DIR%\XUnitTest --no-build" ^
-f "opencover" ^
-o "%COVERAGE_FILE%"
dotnet sonarscanner clear-cache
REM Start SonarScanner analysis
dotnet sonarscanner begin ^
/k:"cni_sonarqube" ^
/d:sonar.cs.opencover.reportsPaths="%COVERAGE_FILE%" ^
/d:sonar.host.url="%SONAR_HOST_URL%" ^
/d:sonar.login="%SONAR_LOGIN%" ^
/d:sonar.sourceEncoding="UTF-8" ^
/d:sonar.projectVersion=1.0.%BUILD_NUMBER%
REM Add .NET tools to PATH
set PATH=%PATH%;C:\Users\Administrator\.dotnet\tools
REM Build the project
dotnet build --no-incremental
REM Complete SonarScanner analysis
dotnet sonarscanner end /d:sonar.login="%SONAR_LOGIN%"
echo Build and SonarQube scan completed.
Problem: Project version is not showing after successful analysis on sonar dashboard, due to which code coverage is giving inaccurate results. since project version is not present sonar is not treating new test cases.
Stuck in this issue since long and still clueless