Issue outdated Connected Mode configuration migration in Visual Studio 2022

Please provide

  • Operating system: Microsoft Windows 10 Enterprise Version 10.0.19045 Build 19045
  • SonarLint plugin version:7.0.0.74072
  • Programming language you’re coding in: C#
  • Is connected mode used:Connected to SonarQube version 10.1.0.73491

And a thorough description of the problem / question:

A few weeks ago the SonarQube server was updated to version 10.1 (from version 8)
Sonarlint plugin was also updated to the latests available.

Today (which is weird to appear so long after the upgrade) my visual studio tells me:
Sonarlint: You’re using an outdated Connected Mode configuration format. Some features will not be available. Please Migrate.

Then I try to migrate using the wizard, which fails with the following error:


[ThreadId 1] [DEBUG] [MigrationWizardXaml] Error during migration: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\MyProject\.sonarlint'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
   at SonarLint.VisualStudio.ConnectedMode.Migration.VsAwareFileSystem.<CheckOutFilesToDeleteAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.VsAwareFileSystem.<DeleteFolderAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.ConnectedModeMigration.<DeleteSonarLintFolderAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.ConnectedModeMigration.<MakeLegacyFileChangesAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at SonarLint.VisualStudio.ConnectedMode.Migration.ConnectedModeMigration.<MakeLegacyFileChangesAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.ConnectedModeMigration.<MigrateImplAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.ConnectedModeMigration.<MigrateAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarLint.VisualStudio.ConnectedMode.Migration.Wizard.MigrationWizardWindow.<MigrateAsync>d__17.MoveNext()
[ThreadId 1] [Migration] Error during migration: Could not find a part of the path 'D:\MyProjectBis\.sonarlint'.
  Run migration again with verbose logging enabled for more information.
[ThreadId 153] [DEBUG] Looking up implementation of 'IGetNotificationsRequest' for version '10.1.0.73491' on thread '153'
[ThreadId 153] [DEBUG] Created request of type 'SonarQube.Client.Api.V6_60.GetNotificationsRequest'.
[ThreadId 153] [DEBUG] Sending Http request:
[ThreadId 153] [DEBUG] Method: GET, RequestUri: 'api/developers/search_events?projects=ISM5&from=2023-07-12T11%3A36%3A33%2B0200', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 191] [DEBUG] Response with HTTP status code 'OK' received.
[ThreadId 191] [DEBUG] {"events":[]}
[ThreadId 159] [DEBUG] Looking up implementation of 'IGetNotificationsRequest' for version '10.1.0.73491' on thread '159'
[ThreadId 159] [DEBUG] Created request of type 'SonarQube.Client.Api.V6_60.GetNotificationsRequest'.

Not finding that folder seems correct because that folder does not exist and it has never existed.

What can we do?

Hi Guillieremo and Welcome back to the community!

The migration is part of the Sonarlint version 7.0 update which is unrelated to the SonarQube update.

Previously when binding to SonarQube / SonarCloud we would create a folder “.sonarlint” next to your solution file with all the relevant connected mode files which is what we were trying to delete in your log.

I will need some more information on your Solutions folder/project structure to determine what the problem is.

  1. When you say that folder has never existed do you simply mean it has not existed in that specific location? and if so could you let me know the actual location of the folder .sonarlint relative to your project?

  2. In the log there are two different projects 1) D:\MyProject and 2) D:\MyProjectBis did you try two migrate it with two separate projects? i.e. first with MyProject and then with MyProjectBis?

Thank you for your time!

1 - There is no such folder, neither relative nor absolute anywhere in the solution folder.

Solution structure is more or less like this where we can see a Sonarqube Folder:

Solution Folder
SonarQube Folder
MyProject Folder
Csharp Folder
- SonarLint.xml
- MyProjectCSharp.ruleset
- SolutionBinding.sqconfig
- sonar.settings.json
Src Folder
Test Folder

Hidden folders are: .git and .vs

Not able to find anything like .sonarlint folder anywhere, not under solution folder, not outside, not under user folders.

2 - My bad, probably during real project name renamed to more generic, MyProject

Thanks so much for your reply!

Is it possible that the last time SonarLint was updated was a few years ago? Because it looks like the binding configuration is from SonarLint 4.0 > which we released back in 2018.

Unfortunately, our migration does not support cleaning up legacy files.

Instead of migrating what I can advise you to do is delete all Sonarlint files from your project (the SonarQube Folder and Csharp Folder) and then make a fresh binding.

This link will show you a walkthrough of how to do so.

Please mind the changes might affect the way you previously dealt with connected mode as the new binding will write all files to %AppData%\Roaming\SonarLint for Visual Studio\Bindings instead of your solution folder.

Please let me know if this helps! :slight_smile:

1 Like

If I try your latest suggestion then Sonarlint does not complain any more.

And I can see all new bindings appear at:
%AppData%\Roaming\SonarLint for Visual Studio\Bindings

It seems that is the way for the future although I am a little afraid it can somehow in the project, specially Azure build agents so we will delay the update a bit.

Is there any way to force binding to appear under solution folder so it is shared and used by all machines?. Do you recommend this approach at all I mean, is it worthy that rules are also stored in the git repo and shared that way? If updated this way, will build agents still be able to compile and show Sonar issues when using normal msbuild?

Hi again!

I am glad that worked. Regarding your questions, we are currently having a discussion around enabling a user to choose if they want to have part of the binding under the solution folder so that it can be shared. It was originally not a feature but rather a result of how we approached writing the binding files which is why we removed it but seeing some of the user input it will likely be an option in the near future.

Now to your second point, with this update building via the CLI will no longer use sonar rule sets. This is another thing that will be discussed to see what we can do to add that functionality back.

What I can recommend is maybe at least update SonarLint to the latest version pre 7.0 which would be 6.16 available here → Releases · SonarSource/sonarlint-visualstudio · GitHub

You will have a newer version of connected mode and more functionality overall while also still being able to keep team-wide binding and building on the CLI. (Mind you this would replace the sonarqube folder with a .sonarlint folder)

lastly, we have had some users struggle with uninstalling SonarLint 7.0 if this happens to you try clearing the .vs folder and restarting your machine that sometimes helps.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.