Error in executing the second command

Hi I have started learning this tool.

on the documentation - I have followed
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/

the Step:

  1. SonarScanner.MSBuild.exe begin /k:“project-key”
  2. MSBuild.exe /t:Rebuild
  3. SonarScanner.MSBuild.exe end

First step was successful and got “Pre-processing succeeded.”

Second step: Got error

PS C:\path to the root Project> SonarScanner.MSBuild.exe ALH_jobScheduleRun /t:Rebuild

SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
WARNING: Please specify the command ‘begin’ or ‘end’ to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Pre-processing started.
Preparing working directories…
17:32:19.462 17:32:19.264 Unrecognized command line argument: ALH_jobScheduleRun
17:32:19.462 17:32:19.451 Unrecognized command line argument: /t:Rebuild
17:32:19.463 17:32:19.451 A required argument is missing: /key:[SonarQube project key]
17:32:19.463 Expecting at least the following command line argument:

  • SonarQube project key
    When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
  • SonarQube project name
  • SonarQube project version
    The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default s
    ettings file in the same directory as the SonarQube Scanner for MSBuild.
    Use ‘/?’ or ‘/h’ to see the help message.
    17:32:19.465 Pre-processing failed. Exit code: 1

Please let me know how to fix this

Thanks

Phil

Anyone to help me on this?

Finally Found a solution.

Special notes to consider:

  • We must use MSBuild Command Prompt for VS2015 instead of regular command prompt or powershell.

  • Add /d:sonar.login=tokenNumber to the cmd

the Step:

  1. SonarScanner.MSBuild.exe begin /k:“project-key” /d:sonar.login=tokenNumber
  2. MSBuild.exe /t:Rebuild
  3. SonarScanner.MSBuild.exe end /d:sonar.login=tokenNumber
  • if the current token key is not working, use another new generated token key.

Hope this helps someone.

Thanks.

1 Like