I have tried to run a SonarQube scan on my C# projects. I have 3 projects and 1 solution file.
I run:
SonarScanner.MSBuild.exe begin /o:"xxxxxxxxx" /k:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
MSBuild.exe Cake.Framework.sln /t:Rebuild
SonarScanner.MSBuild.exe /d:sonar.login="xxxxxxxxxxxxxxxxxxxxxxx" end
Then I see on my cmd:
SonarScanner for MSBuild 4.10
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
Updating build integration targets...
Fetching analysis configuration settings...
Provisioning analyzer assemblies for cs...
Installing required Roslyn analyzers...
Provisioning analyzer assemblies for vbnet...
Installing required Roslyn analyzers...
Pre-processing succeeded.
C:\Users\santi\Desktop\20200422_Cake.Framework-master>MSBuild.exe Cake.Framework.sln /t:Rebuild
Microsoft (R) Build Engine, versión 14.0.23107.0
Everything seems fine but suddenly I got like 1000+ warnings like this one:
CSC : warning CS8032: Couldnt create an analyzer instance
SonarAnalyzer.Rules.CSharp.PartCreationPolicyShouldBeUsedWithExportAttribute from
C:\Users\santi\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. [C:\Users\santi\Desktop\20200422_Cake.Framework-master\Cake.Framework\Cake.Framework.csproj]
I already have installed the Microsoft.CodeAnalysis v 1.3.1 on all my 3 projects using the NuGet Manager.
What I'm missing?
I'm using .NET Framework 4.8, MSBuild 14.0, Visual Studio 2019
You don't need to install the code analysis NuGet packages in your projects.
What matters is the version of the code analysis assemblies that ship with the version of MSBuild you are using to build your solution. Check which version of MSBuild you are using (msbuild -ver
). It needs to 14.0.25420.1
or later.