Visual Studio | Team features | Connected Mode setup

Was this page helpful?

On this page

Install Free

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.

First-time connection setup for shared binding

To begin, one person from the team must follow the steps outlined in Using the connection wizard and Configure your 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

Connected Mode setup

Step 1

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.

The Team Explorer - SonarQube window will help you connect to either SonarQube or SonarCloud.

Step 2

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.

Step 3

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 https://sonarcloud.io
Enter either the SonarQube or SonarCloud server URL into the SonarQube server field.

Step 4

In the Username/Token field, enter a SonarQube or SonarCloud user token and leave the Password field blank.

  • In SonarQube, navigate to User > My Account > Security, or complete this URL, https://<your-sonarqube-url>/account/security/, to generate a new user token.
  • In SonarCloud, navigate to User > My Account > Security, or use this URL, https://sonarcloud.io/account/security, to generate a new user token.

Step 5

Click Connect to set up the connection.

Step 6

(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 from that organization. 

The SonarQube tab now displays your projects and you will also see your organization listed if you are connected to SonarCloud.

Your project list will appear in the Team Explorer - SonarQube view window.

To create and deploy a Shared Connections Binding file, follow the Configure the binding, and Save and share your setup instructions. 

Configure your binding

Bind your project

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

Binding connects your local project to that on the server.

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

Additional notes 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.

Select Add the item to close out the Tfvc pop-ups. They will not appear again.

Once you have dismissed the Tfvc dialogs, they should not appear again.

Save and share your setup: Recommended for teams

Save the connection binding

After completing the steps outlined in the Using the connection wizard section above, go to Visual Studio Extensions > SonarLint > Connected mode and select Export Binding Configuration

A .json file will be added to your .sonarlint folder containing the SonarQube URI & Project Key, or SonarCloud Organization & Project Key. 

Share the connection binding

Commit the file you just created in the working directory; your teammates should have access to the binding configuration once your commit becomes part of the repository.

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 is still required to have their own SonarQube or SonarCloud credentials; these are managed in SonarQube and SonarCloud, respectively

Bind using shared configuration

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. 

The SonarLint for Visual Studio configuration gold bar to help streamline the binding process.

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.

Use the Shared Binding Configuration to help set up Connected Mode in SonarLint for Visual Studio.

Sharing configurations between different IDEs

SonarLint extensions are available for IntelliJ (and other Jet Brains IDEs), Visual Studio, VS Code, and Eclipse. Although the information stored in the shared configuration file is the same, each extension might export the JSON file to a slightly different location depending on IDE and project type. This may cause friction when opening a configuration in an IDE other than the IDE that created it.

If SonarLint does not send you a notification to accept a shared configuration, please check first if you have opened your project’s root. If SonarLint still does not suggest a matching configuration, you must configure binding manually. Please see the Configure your binding collapsible above for instructions.

SonarLint for Visual Studio does not support generic connections. The file name of the shared configuration JSON file must match the currently opened solution name when binding a solution, or the currently opened folder name when binding a folder (for example, in a CMake project).

Project binding

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.

Synchronization with the server

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.

Updating a binding

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:

Right-click on your project to Update the binding.

Local settings

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.

Unbinding a project

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\Bindings folder; delete the associated project folder.

Legacy Connected Mode

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.

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License