Connected Mode setup
SonarLint for Visual Studio provides a connection wizard to help you set up Connected Mode with SonarQube or SonarCloud. From version 7.4, it is possible to share a setup configuration file with your team, simplifying the process.
One team member must step through the First-time setup process, then export and commit the binding configuration to the repo. Any team member with project credentials running SonarLint will find the binding details inside of the project’s source folder.
To begin, one person from the team must follow the steps outlined in Using the connection wizard and Configure the binding, then follow the Save and share your setup instructions to save the project configuration for the rest of the team.
Using the connection wizard
In Visual Studio, go to Extensions > SonarLint > Connected mode and select Bind to SonarQube or SonarCloud…, this will open the SonarQube Connections tab in the Team Explorer window. Although the tab reads SonarQube, it is used for connecting to both SonarQube and SonarCloud.
If you see a checkbox to choose Use Shared Binding Configuration, someone in your team has already setup a configuration. If you want to use this shared connection, stop, and skip to the Load a shared connection setup paragraph below.
For new connections, click Connect… to open the connection dialog box.
The Connect to a SonarQube Server tab is used for connecting to both SonarQube and SonarCloud.
In the SonarQube Server field:
- If you’re connecting to SonarQube: enter your SonarQube server address.
- If you’re connecting to SonarCloud: enter your SonarCloud server URL that starts with
User tokens are required when setting up Connected Mode between SonarQube and SonarLint. Note that the binding will not function properly if project tokens or global tokens are used during the setup process. Check the SonarLint documentation for more details
Click Connect to set up the connection.
(for SonarCloud only) Select the organization you want to bind to and click OK. To bind to a third-party organization that is not on the list, go to Other organizations and enter the organization key.
The SonarQube tab now displays your projects; you will also see your organization if you are connected to SonarCloud.
To create and deploy a Shared Connections Binding file, follow the Configure the binding, and Save and share your setup instructions.
Configure your binding
To bind a project, go to Visual Studio Team Explorer > Your SonarQube instance and double-click the project you want to bind; alternatively, you can right-click on your project and select Bind.
The Connected Mode binding settings are written under %AppData%\Roaming\SonarLint for Visual Studio\Bindings. Each bound solution will have its own folder.
SonarLint automatically fetches the required settings from the server and creates local configuration files. To manually trigger an update, go to Visual Studio Team Explorer > SonarQube, right-click the project whose binding you want to update, and select Update.
To share your binding configuration, follow the Save and share your setup instructions.
For Tfvc users
If you are using Team Foundation Version Control and have C# or VB.NET projects in your solution, it is possible that you will see some additional dialogs from Tfvc appearing when binding finishes. If your solution does not contain C# or VB.NET projects, you can disregard the rest of this section.
Tfvc might pop up one or more dialogs like the one below warning that files outside the workspace are being referenced and asking for confirmation that this is ok. These files are used to configure analysis for C# and VB.NET, and do not need to be under source control. Select
Add the item to dismiss the dialog.
Once you have dismissed the Tfvc dialogs, they should not appear again.
Recommended for Teams: Save and share your setup
After completing the steps outlined in the Using the connection wizard section above, go to Visual Studio Extensions > SonarLint > Connected mode and select Save Shared Connection Binding. A .json file will be added to your .sonarlint folder containing the SonarQube URI & Project Key, or SonarQube Organization & Project Key.
Commit this file to make it available to your team.
Because your Project’s identifying information is saved in a location under source control, it will be available to anyone with access to the project repo. Each team member are still required to have their own SonarQube or SonarCloud credentials.
Once the shared project configuration has been saved by one team member, additional team members will have a streamlined process when configuring their project binding. To achieve this, SonarLint automatically looks for the .sonarlint folder; if it’s available and the shared configuration file is there, SonarLint will offer you a gold bar to streamline the setup.
Select the Bind option from the gold bar to set up your connection to the server using the shared settings. If you wish to opt-out, use of the shared connection settings are available when you start a new connection setup.
If no gold bar is available, in Visual Studio, go to Extensions > SonarLint > Connected mode and select Bind to SonarQube or SonarCloud…, this will open the SonarQube Connections tab.
Simply select the Use Shared Binding Configuration checkbox and click Connect…. If you’re not already connected to the same instance of SonarQube or SonarCloud, you will be prompted to enter your credentials; with the correct stored credentials, the project will bind immediately with a single click.
When you bind a project, SonarLint uses the Quality Profile defined on the server to decide which rules to run locally, and which rule parameters to use. When you mark a particular issue as “safe” or “won’t fix” on the server, the corresponding issue will be ignored in the IDE. Check the SonarQube or SonarCloud documentation for details about managing your quality profile.
The local Connected Mode configuration files can sometimes get out of step with settings on the SonarQube or SonarCloud servers for example, when a quality profile for the project is changed (on the server).
Synchronization between the SonarQube server is almost instantaneous. For example, when changes are made to the quality profile, the SonarQube server sends SonarLint an event notice; with SonarCloud, SonarLint checks the SonarCloud server every ten minutes to listen for changes.
In most cases, there should be no need to trigger a manual update on your Connected Mode binding to sync suppressed issues. However, to manually trigger an update to your Connected Mode binding, go to Visual Studio Team Explorer > SonarQube, right-click the project whose binding you want to update, and select Update:
If you are running SonarLint for Visual Studio v6.16 or earlier, please see the Previous versions page for information about how server synchronization is managed. Before v7.0 (released in June 2023), Connected Mode behaved a bit differently; check the Migrate Connected Mode to v7 page for more details.
It is not possible to unbind a project from the Visual Studio UI however, this feature is on the Team's backlog. Nevertheless, it is possible to manually remove a solution from Connected Mode:
- Delete the bindings folder associated with your project: Each bound solution will have a separate folder that is located in the
%AppData%\SonarLint for Visual Studio\Bindingsfolder; delete the associated project folder.
Before SonarLint for Visual Studio version 7.0 (released in June 2023), Connected Mode behaved a bit differently. Please see the Previous versions page for the important details.
© 2015-2023, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under the GNU Lesser General Public License, Version 3.0. SONARLINT is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners. See SonarSource.com for everything you need to know about the Sonar Solution.