Using devenv.com with manual step, Analyzer "sees" no source

  • Using SonarScanner 4.7.0.2747, running on Windows Server on a C# project.
  • We are trying to get the scanner recognizing source code when building via devenv.com. MSBuild is NOT an option.
  • Downloaded the stand alone scanner and called it like this:
    sonar-scanner-windows\bin\sonar-scanner.bat -Dsonar.host.url=http://c-dev-sonar:9000 -Dsonar.login=xxx -Dsonar.projectKey=yyy -Dsonar.cs.analyzer.projectOutPaths=sonar

The scanner runs, and uploads a report to the SonarQube instance. There it shows up as “The main branch has no lines of code”
The scanner clearly sees there are files. But it doesn’t scan them. Why?

Log looks like this:

INFO: Load active rules
INFO: Load active rules (done) | time=549ms
INFO: Indexing files…
INFO: Project configuration:
INFO: Excluded sources: Properties/AssemblyInfo.cs, /?cripts/
INFO: 125 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for cs: Sonar way
INFO: ------------- Run sensors on module IBANBankAccountService
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=16ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/sa_ci-admin/.sonar/cache/a89f1943fc75b65becd9fb4ecab8d913/sonar-tsql-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO: Sensor SonarCSS Rules [cssfamily]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=0ms
INFO: Sensor C# Properties [csharp]
WARN: Analyzer working directory does not exist: ‘sonar\output-cs’. Analyzer results won’t be loaded from this directory.
WARN: No Roslyn issues report found for this project.
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=16ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=0ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor JavaSecuritySensor [security]
INFO: Reading type hierarchy from: D:\agent2_work\1\s.scannerwork\ucfg2\java
INFO: Read 0 type definitions
INFO: Reading UCFGs from: D:\agent2_work\1\s.scannerwork\ucfg2\java
INFO: No UCFGs have been included for analysis.
INFO: Sensor JavaSecuritySensor [security] (done) | time=0ms
INFO: Sensor CSharpSecuritySensor [security]

Hi,

C# analysis requires SonarScanner for .NET, and that requires MSBuild.

If MSBuild isn’t an option in your build system, then how are you compiling your code?

 
Ann

devenv.com builds C# projects fine. Could be it used MSBuild under the hood, but it isn’t accessible for the scanner.
Isn’t there some sort of buildwrapper similar to the one for C++ projects?

devenv.com MySolution.sln /Rebuild Release

Hi,

The Scanner for MSBuild is the build wrapper for C#.

 
:woman_shrugging:
Ann

It would be helpful if I’d get an email info on a reply :slight_smile:

The wrapper for C++ works with devenv, while the C# wrapper doesn’t. Quite a difference actually.

Hi,

That’s down to your account preferences:

 
Ann