The https://sonarcloud.io/project/configuration page says "And add the bin directory to the %PATH% environment variable"

add what bin directory? my project’s bin folder?

the sonar scanner doesnt come with a bin folder.

Also its impossible to report this problem anywhere else. Sorry if this isnt the right place.

Also both Powershell and CMD bark when running the command given on the page.

SonarScanner.MSBuild.exe begin \
  /o:"MyOrgName" \
   /k:"MyProject" \
   /d:sonar.host.url="https://sonarcloud.io"
   .\My.sln
SonarScanner.MSBuild.exe end

Neither works. Both CLI error

Someone needs to update the documentation on that page to properly represent the commands to run. \ is not a line continuation character for any native windows cli, but that shouldn’t even be necessary to specify.

PS> SonarScanner.MSBuild.exe begin /o:"MyOrgName"  /k:"MyProject" /d:sonar.host.url="https://sonarcloud.io"
<it reports about 10 lines of output>

PS> msbuild.exe    .\My.sln /t:Clean,Build
<the usual build log output>

PS> SonarScanner.MSBuild.exe end

That is the correct syntax for powershell for this command using msbuild.exe. Substitute dotnet build if you like typing more (or want to be trendy)

Even after that I get

ERROR: JAVA_HOME not found in your environment, and no Java
       executable present in the PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation, or add "java.exe" to the PATH

But I’m running a scan for .net, not Java. Is Java a prereq? I dont see it on the sonarscanner install page and would love to avoid installing that and getting the constant “update me now” notifications if possible.

Yes, Java 8 or 11 is a prerequisite for SonarScanners:

Thanks, I installed 15 and its working for that. I went back to the page in the title and then to the link it has for “SonarScanner installation instructions” (.net, windows, msbuild), and scrolled down the entire page not seeing anything about prereqs.

Then I realized the link had dumped me to an anchor on the page after the prereqs.

So to recap, the Windows directions are vague WRT “bin” folder (it means the directory where the sonar scanner’s exe is). The examples are written for Bash (i think), and the configure analysis page links to a section later than when it probably should.

1 Like