Search code examples
sonarqubesonarqube-msbuild-runner

SonarQube MSBuild scanner stopping after pre-processing


I'm trying to get SonarQube setup on our tfs build server and it keeps stopping the scan after pre-processing succeeds. I'm using the MSBuild.SonarQube.Runner.exe. There are no error messages at all. No indication that anything has gone wrong. I'm not sure where to go from here. Halp?

cmd-screenshot


Solution

  • There's nothing wrong in what you see as the output. You are just missing some bits and pieces.

    The “begin” invocation sets up the SonarQube analysis. Mandatory analysis settings such as the SonarQube project key, name and version must be passed in, as well as any optional settings, such as paths to code coverage reports. During this phase, the scanner fetches the quality profile and settings to be used from the SonarQube server.

    Then, you build your project as you would typically do. As the build happens, the SonarQube Scanner for MSBuild gathers the exact set of projects and source files being compiled and analyzes them.

    Finally, during the “end” invocation, remaining analysis data such as Git or TFVC one is gathered, and the overall results are sent to the SonarQube server.

    Source

    In short, after the first command call (begin), you need to run MSBuild 14.0 and build your solution, then finish up the invocation (end) and see the analysis results in your SonarQube server, if everything went all right.

    # This is part of the pre-build script
    > MSBuild.SonarQube.Runner.exe begin /k:project_key /n:project_name /v:project_version
    
    # Build your solution here
    > msbuild /t:rebuild
    
    # This is part of the post-build script
    > MSBuild.SonarQube.Runner.exe end
    

    That small script should be part of your build pipeline (using Jenkins, TeamCity, or whatever CI tool) ideally.

    Hope this helps!