Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# code not analyzed - Version 7.3 (build 5690) #1828

Closed
franciscoarturoalonso opened this issue Sep 3, 2018 · 5 comments
Closed

C# code not analyzed - Version 7.3 (build 5690) #1828

franciscoarturoalonso opened this issue Sep 3, 2018 · 5 comments
Assignees

Comments

@franciscoarturoalonso
Copy link

Description

Configured a local instance of SonarQube 7.2.1
Trying to analyze a solution targeting .Net 4.5.2
Getting the analysis only for the JavaScript files, nothing for the cs files, they are shown in the project but no results for them.

Getting a lot of messages like these in the build:
CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.ThreadStaticWithInitializer cannot be created from C:\Users\user\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. [\\Repositories\_GitHubRepo\.D\.D.csproj] CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.MutableFieldsShouldNotBePublicReadonly cannot be created from C:\Users\user\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. [\\Repositories\_GitHubRepo\.D\.D.csproj] CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.GetHashCodeEqualsOverride cannot be created from C:\Users\user\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. [\\Repositories\_GitHubRepo\.D\.D.csproj]

The dlls and assembly are in place.

And these warnings in the end step:

WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project. WARN: No roslyn issues report not found for this project. WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project. WARN: No roslyn issues report not found for this project. WARN: Analyzer working directory does not exist: 'D:\\Repositories\_GitHubRepo\.sonarqube\out\0\output-cs'. Analyzer results won't be loaded from this directory. WARN: Analyzer working directory does not exist: 'D:\\Repositories\_GitHubRepo\.sonarqube\out\1\output-cs'. Analyzer results won't be loaded from this directory. WARN: Analyzer working directory does not exist: 'D:\\Repositories\_GitHubRepo\.sonarqube\out\2\output-cs'. Analyzer results won't be loaded from this directory. WARN: Too many duplication references on file /Scripts/jquery-1.10.2.intellisense.js for block at line 2. Keep only the first 100 references. WARN: Too many duplication references on file /Scripts/jquery-1.10.2.intellisense.js for block at line 2. Keep only the first 100 references. WARN: Too many duplication references on file /Scripts/jquery-1.10.2.intellisense.js for block at line 2. Keep only the first 100 references.

Repro steps

"C:\Program Files\sonarqube-7.2.1\sonnarscanner-msbuild\net46\SonarScanner.MSBuild.exe" begin /k:MyKey /d:sonar.verbose=true > BEGIN

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" /t:Rebuild .\Solution.sln > BUILD

"C:\Program Files\sonarqube-7.2.1\sonnarscanner-msbuild\net46\SonarScanner.MSBuild.exe" end > END

Expected behavior

Report on the C# code.

Actual behavior

Only results for the JavaScript code.

Known workarounds

Please provide a description of any known workarounds.

Related information

  • SonarC# Version 7.3 (build 5690)
  • Visual Studio Version 2017 15.6.1
  • If running through the Scanner for MSBuild, its version SonarScanner for MSBuild 4.3.1

Please, let me know if there's more information needed to help diagnose.
Thanks in advance for your help!

Francisco.

@Evangelink Evangelink added this to the Support milestone Sep 3, 2018
@Evangelink Evangelink self-assigned this Sep 3, 2018
@Evangelink
Copy link
Contributor

Hi @franciscoarturoalonso,

If you look at the release notes of SonarC# 7.0 you will see that we talk about a breaking change which forces you to have at least VS2015 Update 3 or MSBuild 14 Update 3 (the latest available for download on Microsoft website).

The warnings you are referring to are because we rely on Roslyn 1.3.1 (Microsoft.CodeAnalysis) which is shipped by default with VS/MSBuild. As you don't have the correct version of VS/MSBuild then the analyzer is crashing.

@franciscoarturoalonso
Copy link
Author

Thanks for your quick response @Evangelink,

I have tried with these two MSBuild versions:
Microsoft (R) Build Engine version 14.0.23107.0
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Framework (from Visual Studio)

And none seems to work, I'm still missing something there.

@Evangelink
Copy link
Contributor

Hi @franciscoarturoalonso,

Sorry for this really late answer but I was off before. Could you check if one of your projects is referencing the Microsoft.Net.Compilers nuget? If so you need to update it to at least 1.3.1

If you still have any issue, could you try and create a small console app and analyze it to see if you also have the issue or not?

Cheers,
Amaury

@franciscoarturoalonso
Copy link
Author

franciscoarturoalonso commented Oct 19, 2018 via email

@sunrong1
Copy link

Hi @franciscoarturoalonso,

Sorry for this really late answer but I was off before. Could you check if one of your projects is referencing the Microsoft.Net.Compilers nuget? If so you need to update it to at least 1.3.1

If you still have any issue, could you try and create a small console app and analyze it to see if you also have the issue or not?

Cheers,
Amaury

Thanks a lot. It takes my three days to solve the problem.My project is built in VS2017,and my sornarQube's version is 7.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants