SonarSource / sonar-scanner-msbuild

SonarScanner for .NET
http://redirect.sonarsource.com/doc/msbuild-sq-runner.html
GNU Lesser General Public License v3.0
364 stars 142 forks source link

Explicitly document that the begin, build and end steps should be run from the same folder #1318

Open duncanp-sonar opened 2 years ago

duncanp-sonar commented 2 years ago

Description

The docs don't make it clear that the begin, MSBuild and end steps have to executed from the same directory (data is passed between the stages by writing files in subfolders relative to the working directory, so changing the working directory means the files won't be found).

Related community thread

duncanp-sonar commented 2 years ago

Alternative approach (requires more testing)

Run the begin and end steps from the same directory (the "scanner working directory"). The working directory for the build step can be different, as long as it is told where the scanner working directory is.

e.g.

:: Change to the directory to be used as the scanner working directory
cd D:\Junk\ScannerTest
call d:\Tools\scanner\latest\net46\SonarScanner.MSBuild.exe begin /d:sonar.login=%1 /k:duncanp_junk /d:sonar.host.url=https://sonarcloud.io /o:duncanp-sonar-test

:: Change to the build directory, and tell MSBuild where the scanner working directory is
cd D:\support\scanner\CSNetClassLib1
msbuild /t:rebuild /p:SonarQubeBuildDirectory=D:\Junk\ScannerTest

:: Switch back to the scanner working directory for the end step
cd D:\Junk\ScannerTest
d:\Tools\scanner\latest\net46\SonarScanner.MSBuild.exe end /d:sonar.login=%1