I also have a Windows Server 2019 working as a node of Jenkins, where I deploy my C# project.
#What I am trying to achieve
I’ve configured a job in Jenkins which:
Downloads the C# project from Git to the node
Analyzes with Sonarqube the static code it just downloaded
#The output I get once the job finishes
The Build in Jenkins succeeds, but the console output says:
INFO: Sensor C# [csharp] WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see SonarScanner for .NET INFO: Sensor C# [csharp] (done) | time=1ms
I’m relatively new here, but I’m using sonarscanner locally for C# projects and have not yet had this issue. My C# projects target the .Net 5 and .Net 6 frameworks. Which frameworks do you target?
If your projects do not target .Net 5 or higher, then it might be time to upgrade your target frameworks, as LTS is ending for 3.1 at the end of this year.
Otherwise, can you check your version of sonarscanner and confirm that it has support for .Net 5.x or higher? You can check that in the listed version here under the header “SonarScanner for .NET”. If it doesn’t, then you might have to reinstall sonarscanner to a version that does support .Net 5.x or higher
Tip: Running the dotnet tool install command without a version will install the most recent version.
To add onto @cwata’s answer – it looks like you are using the Jenkins steps that directly use the SonarScanner CLI. It is also possible to select steps that use the Scanner for MSBuild / .NET, which is required for the analysis of C# code.
Hi @Colin and @cwata, thank you guys for replying!
The framework I’m targetting is .Net 4.7.
My Jenkins installs from Maven Central the SonarQube Scanner version 4.7.0.2747.
I don’t really know if this version is compatible with .Net 4.7. If not I can try installing a later version from command.
Anyways, according to what @Colin proposes, is it mandatory to build the project? I mean, is it possible to scan the static code (as plain text code) as I do in other projects such as python, java, … without building it?
A few languages (Java, C#, C/C++/Objective-C) are considered compiled languages and require a build for analysis to take place. There are some workarounds with Java (which result in worse analysis results) – there is no workaround for .NET.