Legacy Windows Workflow / XAML-based build system
The following section refers to the new build system available since Team Foundation Server 2015 and on VSTS. Refer to the Team Foundation Server 2013 documentation if you are using the Windows Work / XAML-based build system.
Hosted build agents on Visual Studio Team Services already meet the prerequisites listed here.
- Make sure the .NET Framework v4.5.2+ is installed
- Make sure the Java Runtime Environment v7u75+ is installed
Add a SonarQube Service endpoint
- From the Team Project settings manager, click on Services
- Create a new Generic Service Endpoint
- Enter the SonarQube server and credentials and click Ok
Note: If you wish to use an analysis token instead of a username and password, enter it under User name field
Enable the SonarQube analysis in the build definition
- Open the new build definition or edit build definition interface
- Open the Add build step... dialog
- Add both the SonarQube for MSBuild - Begin Analysis and SonarQube for MSBuild - End Analysis build steps to your build definition
- Click on the SonarQube for MSBuild - Begin Analysis build step to open its configuration dialog
- Select the SonarQube Endpoint to be used for the analysis
- Configure the SonarQube Project Key, Name and Version
The actual build of your project should occur in between the SonarQube begin and end analysis stepsRefer to the Compatibility with Visual Studio and MSBuild notes.You can also build your project using the MSBuild build step instead of the Visual Studio Build step.
- Optional: To import code coverage into SonarQube, add the Visual Studio Test build task after the build one and tick Code Coverage Enabled
- Save the build definition
Launch a new build, wait for it to complete. If the build succeeded, you should now see a new SonarQube section on the build dashboard: