SonarQube MSBuild integration failure

I am getting the following error when I try to run the SonarScanner MSBuild.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin>cd “C:\SonarQube\sonar-scanner-msbuild-”

C:\SonarQube\sonar-scanner-msbuild->SonarScanner.MSBuild.exe end /d:sonar.login=“admin” /d:sonar.password=“admin”
SonarScanner for MSBuild 4.10
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:

  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
    12:04:13.846 Post-processing failed. Exit code: 1

You need to build your project for example:

Sonarscanner.msbuild.exe begin /k:“projectkey” /n:“project-name”
msbuild.exe “path-to-project.sln” /t:Rebuild
Sonarscanner.msbuild.exe end

So think of it like begin, build and then end (where the end bit actually scans an uploads to sonarqube).

Hope this helps.