CSharp/SonarLint.xml could not be found

Hi all,

I’m new to Sonarqube. We’ve integrated Sonarqube 9.1 with Azure DevOps Server 2019. While analyzing our code, I’m getting below error. I couldn’t find where the problem is. Can you guide me on that?


  Restored /src/Auth/ToniDigital.Services.Auth.Abstractions/ToniDigital.Services.Auth.Abstractions.csproj (in 42 ms).
  Restored /src/Auth/ToniDigital.Services.Auth.Services/ToniDigital.Services.Auth.Services.csproj (in 48 ms).
  Restored /src/Auth/ToniDigital.Services.Auth.Repository/ToniDigital.Services.Auth.Repository.csproj (in 24 ms).
  Restored /src/Auth/ToniDigital.Services.Auth/ToniDigital.Services.Auth.csproj (in 172 ms).
  ToniDigital.Services.Auth.Entities -> /app/build/ToniDigital.Services.Auth.Entities.dll
  ToniDigital.Services.Auth.IRepository -> /app/build/ToniDigital.Services.Auth.IRepository.dll
  ToniDigital.Services.Auth.Abstractions -> /app/build/ToniDigital.Services.Auth.Abstractions.dll
/src/Auth/ToniDigital.Services.Auth.Services/Services/AuthTokenService.cs(44,39): warning CS1573: Parameter 'logger' has no matching param tag in the XML comment for 'AuthTokenService.AuthTokenService(IOptions<TokenConfig>, IApiKeyRepository, ISecurityProvider, ITokenProvider, ITokenRepository, IUserRepository, ILogger<AuthTokenService>)' (but other parameters do) [/src/Auth/ToniDigital.Services.Auth.Services/ToniDigital.Services.Auth.Services.csproj]
  ToniDigital.Services.Auth.Services -> /app/build/ToniDigital.Services.Auth.Services.dll
  ToniDigital.Services.Auth.Repository -> /app/build/ToniDigital.Services.Auth.Repository.dll
CSC : error CS2001: Source file '/src/Auth/ToniDigital.Services.Auth/../../.sonarlint/service-products/CSharp/SonarLint.xml' could not be found. [/src/Auth/ToniDigital.Services.Auth/ToniDigital.Services.Auth.csproj]

Build FAILED.

/src/Auth/ToniDigital.Services.Auth.Services/Services/AuthTokenService.cs(44,39): warning CS1573: Parameter 'logger' has no matching param tag in the XML comment for 'AuthTokenService.AuthTokenService(IOptions<TokenConfig>, IApiKeyRepository, ISecurityProvider, ITokenProvider, ITokenRepository, IUserRepository, ILogger<AuthTokenService>)' (but other parameters do) [/src/Auth/ToniDigital.Services.Auth.Services/ToniDigital.Services.Auth.Services.csproj]
CSC : error CS2001: Source file '/src/Auth/ToniDigital.Services.Auth/../../.sonarlint/service-products/CSharp/SonarLint.xml' could not be found. [/src/Auth/ToniDigital.Services.Auth/ToniDigital.Services.Auth.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:12.63
The command '/bin/sh -c dotnet build "ToniDigital.Services.Auth/ToniDigital.Services.Auth.csproj" -c Release -o /app/build' returned a non-zero code: 1
##[error]The command '/bin/sh -c dotnet build "ToniDigital.Services.Auth/ToniDigital.Services.Auth.csproj" -c Release -o /app/build' returned a non-zero code: 1
##[error]/usr/bin/docker failed with return code: 1

Hi @ramazankilimci - welcome to the community.

It looks like the problem is caused by the interaction of two different parts of the product - SonarQube, and SonarLint.

SonarLint is an IDE extension that provide on-the-fly analysis at development time. It can be used on its own (standalone mode), or if you are also using SonarQube it can be used in Connected Mode (so the configuration is synchronised with SonarQube).

The error message shows the compiler is complaining about missing files in the .sonarlint/service-products/CSharp/... directory. That directory is added by SonarLint when Connected Mode is being used, and the MSBuild project files are modified to refer to files in the directory.

My guess is that someone has tried to set up Connected Mode, but has only committed some of the changes to source control e.g. they have committed the changes in the MSBuild project files, but not added the files in the .sonarlint folder.

You could try one of the following:
a) adding the missing files to source control, or
b) removing the Connected Mode changes from the MSBuild project files.
You can find more information about the specific changes made by Connected Mode here.

One thing I don’t understand is why the error message refers to the file as a Source file, since it isn’t a C# file. Could you share the verbose build logs please? (pass -v:diag to the dotnet build command).