Install Free
Visual Studio | Team features | Connected Mode setup

Connected Mode setup

On this page

Connection setup

SonarLint for Visual Studio provides a connection wizard to help you set up Connected Mode with SonarQube or SonarCloud. From version 7.4, you can share a setup configuration file with your team, simplifying the process. 

Automatic setup

SonarQube 10.4+ offers the easiest way to set up Connected Mode: simply use the Open in IDE feature from SonarQube. You must trust the SonarQube server to store a token for the connection, and it's best if you already have the project open in your IDE. 

If something doesn’t work, check the Troubleshooting article, or follow the instructions below to manually create a SonarQube connection.

Create a new SonarQube Connection

Open the SonarLint Manage Project Binding wizard in Visual Studio by navigating to Extensions > SonarLint > Connected Mode > Bind to SonarQube or SonarCloud…. The current Binding Status will be shown. Next, select Manage connections to open a list of your Existing Connections and choose New Connection to create a new connection.

Choose SonarQube as your connection type, enter your SonarQube URL and select Next to continue. 

Add the SonarQube server details to set up your connection with SonarLint.

You have the option to select your Authentication type; please note that Credentials is deprecated and authenticating with a Token is recommended.

  • To generate a new user token, navigate to User > My Account > Security in SonarQube or simply use the Generate hyperlink to open the page in SonarQube, which will use the URL you provided earlier.

The final steps involve binding your local project to the project on the server. See below for more details.

Automatic setup

SonarCloud offers the easiest way to set up Connected Mode: simply use the Open in IDE feature from SonarCloud. You must trust the SonarCloud server to store a token for the connection, and it's best if you already have the project open in your IDE. 

If something doesn’t work, check the Troubleshooting article, or follow the instructions below to manually create a SonarCloud connection.

Create a new SonarCloud Connection

Open the SonarLint Manage Project Binding wizard in Visual Studio by navigating to Extensions > SonarLint > Connected Mode > Bind to SonarQube or SonarCloud…. The current Binding Status will be shown. Next, select Manage connections to open a list of your Existing Connections and choose New Connection to create a new connection. Select Next to continue.

Choose SonarCloud as your connection type and select Next to continue. 

Add the SonarCloud server details to set up your connection with SonarLint.

You have the option to select your Authentication type; please note that Credentials is deprecated and authenticating with a Token is recommended.

  • To generate a new user token, navigate to User > My Account > Security in SonarCloud or use the Generate hyperlink to open this page on SonarCloud.

Then, choose one of your organizations from the list, and select OK. If you don’t see the organization you want in this list, select Choose another organization and manually enter its organization key.

The final steps involve binding your local project to the project on the server. See below for more details.


First-time connection setup for shared binding

One team member must step through the first-time setup process, then export and commit the binding configuration to the repository. Any team member who opens the project while running SonarLint will automatically receive a notification to bind the project. Each team member must use their own project credentials and SonarLint will use the binding details found in the configuration file to complete the connection.

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 below to save the project configuration for the rest of the team. 

Using the connection wizard

Connected Mode

Follow the Connection setup instructions above for your SonarQube or SonarCloud connection.

Configure your binding

Bind your project

After creating a connection and with the Manage Project Binding wizard open, choose your Connection to bind to define the server and select the Select project button to define the Project to bind. The Select project button will open a list of your projects on the server. 

Choose the project you want to bind, select the Select button, and select Bind.

You will receive a confirmation if the binding is a success. 

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.

Each team member is still required to have their own SonarQube or SonarCloud connection and credentials.

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. 

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

Select the Bind option from the gold bar to continue setting up your connection to the server using the shared settings. If you already have a connection to the correct server, the binding will start automatically. 

If you don’t already have a connection, you will receive a notification. In this case, click OK on the notification and select Manage connections from the Manage Project Binding wizard to manually create a connection. In the Manage connections window, step through the connection setup by selecting either SonarQube or SonarCloud to add your user token, as it is described above in Connection setup.

If you wish to opt out of using the shared connection settings and select Don’t show this again, the gold bar will no longer appear. To accept a shared configuration, select the Use Shared Configuration option from the Manage Project Binding window.

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.

Unbinding a project

To unbind a SonarQube or SonarCloud project, delete the bindings folder associated with your project. 

Each bound solution will have a unique folder in the %AppData%\Roaming\SonarLint for Visual Studio\Bindings folder; delete the correct project folder to remove the binding.

Updating your credentials

Unfortunately, you cannot update your SonarQube or SonarCloud credentials in SonarLint for Visual Studio but the feature is in the development team’s backlog. 

Should, for example, your SonarQube or SonarCloud user token expire and you want to keep using Connected Mode, you must delete and recreate the connection. Here is the procedure: 

  1. If you have any project bound to the connection you want to delete, first manually delete each binding (bound with that connection) as described above in Unbinding a project
    • If there is no project binding, move on to Step 2.
  2. Open the SonarLint Manage Project Binding wizard (Extensions > SonarLint > Connected Mode > Bind to SonarQube or SonarCloud…), select Manage connections and delete the connection you want to remove. You cannot delete a connection if it has a project binding.
  3. Finally, recreate your connection with your new token and rebind your project. 

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. 

In addition, the process of setting up Connected Mode in versions 8.3 and earlier looks a bit different; all of this content was moved to the Legacy Connected Mode article on the Previous versions page.


Was this page helpful?

© 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