ASP.Net Project - Converted to Web App - only shows .config files

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this
    Sonarqube 10.5.1 Community
    Deployed as zip on RHEL8
    Sonarscanner.MSBuild.exe 6.2.0 (deployed to Windows 2019 with Visual Studio project)

Scanning of a DotNet Framework Web Application. It was ASP.Net Site, but have converted to a web application upon reading SonarScanner for .NET (sonarsource.com)

Project scans, and uploads a report. But it only shows lines of code for the web.config files. None of the .cs code files seem to show any lines of code (or issues)

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

At one point I can see it collecting all the files:

17:09:47.203 INFO:   Base dir: E:\Users\xxxxx\Git\WS-DocServices\EMCDocServices-WebApp
17:09:47.204 DEBUG:   Source paths: Properties/AssemblyInfo.cs, Service.asmx, ServiceV2.asmx, ServiceV2WNZL.asmx, Web References/RetrievePDF/Reference.map, Web.config, Web References/Audit/Reference.map, Web References/Logon/Reference.map, Web References/Logon/UserObj.datasource, App_Code/Service.cs, App_Code/ServiceV2.cs, App_Code/ServiceV2WNZL.cs, App_Code/Util.cs, App_Code/Classes/ContentInfo.cs, App_Code/Classes/DataAccess.cs, App_Code/Classes/DocTypeSchema.cs, App_Code/Classes/EMCConnectionException.cs, App_Code/Classes/OperationStatus.cs, App_Code/Classes/SearchResult.cs, App_Code/Classes/UserData.cs, Properties/Settings.settings, Web References/Audit/Audit.disco, Web References/Logon/Logon.disco, Web References/RetrievePDF/Service.disco, Web References/Logon/Logon.wsdl, Web References/RetrievePDF/Service.wsdl, packages.config, Web References/Audit/Audit.wsdl, Web.Debug.config, Web.Release.config
17:09:47.205 INFO:   Excluded sources: sonar_scan_bin.sh, sonar_scan_sbin.sh
17:09:47.231 DEBUG: 'Properties/AssemblyInfo.cs' generated metadata with charset 'UTF-8'
17:09:47.237 DEBUG: 'Properties\AssemblyInfo.cs' indexed with language 'cs'
17:09:47.243 DEBUG: 'Service.asmx' indexed with no language
17:09:47.244 DEBUG: 'ServiceV2.asmx' indexed with no language
17:09:47.245 DEBUG: 'ServiceV2WNZL.asmx' indexed with no language
17:09:47.246 DEBUG: 'Web References\RetrievePDF\Reference.map' indexed with no language
17:09:47.246 DEBUG: 'Web.config' indexed with language 'xml'
17:09:47.247 DEBUG: 'Web References\Audit\Reference.map' indexed with no language
17:09:47.248 DEBUG: 'Web References\Logon\Reference.map' indexed with no language
17:09:47.250 DEBUG: 'Web References\Logon\UserObj.datasource' indexed with no language
17:09:47.251 DEBUG: 'App_Code\Service.cs' indexed with language 'cs'
17:09:47.251 DEBUG: 'App_Code\ServiceV2.cs' indexed with language 'cs'
17:09:47.252 DEBUG: 'App_Code\ServiceV2WNZL.cs' indexed with language 'cs'
17:09:47.252 DEBUG: 'App_Code\Util.cs' indexed with language 'cs'
17:09:47.253 DEBUG: 'App_Code\Classes\ContentInfo.cs' indexed with language 'cs'
17:09:47.253 DEBUG: 'App_Code\Classes\DataAccess.cs' indexed with language 'cs'
17:09:47.254 DEBUG: 'App_Code\Classes\DocTypeSchema.cs' indexed with language 'cs'
17:09:47.255 DEBUG: 'App_Code\Classes\EMCConnectionException.cs' indexed with language 'cs'
17:09:47.255 DEBUG: 'App_Code\Classes\OperationStatus.cs' indexed with language 'cs'
17:09:47.256 DEBUG: 'App_Code\Classes\SearchResult.cs' indexed with language 'cs'
17:09:47.256 DEBUG: 'App_Code\Classes\UserData.cs' indexed with language 'cs'
17:09:47.257 DEBUG: 'Properties\Settings.settings' indexed with no language
17:09:47.259 DEBUG: 'Web References\Audit\Audit.disco' indexed with no language
17:09:47.260 DEBUG: 'Web References\Logon\Logon.disco' indexed with no language
17:09:47.262 DEBUG: 'Web References\RetrievePDF\Service.disco' indexed with no language
17:09:47.262 DEBUG: 'Web References\Logon\Logon.wsdl' indexed with no language
17:09:47.263 DEBUG: 'Web References\RetrievePDF\Service.wsdl' indexed with no language
17:09:47.264 DEBUG: 'packages.config' indexed with language 'xml'
17:09:47.265 DEBUG: 'Web References\Audit\Audit.wsdl' indexed with no language
17:09:47.265 DEBUG: 'Web.Debug.config' indexed with language 'xml'
17:09:47.265 DEBUG: 'Web.Release.config' indexed with language 'xml'

And skipping over some generated Web References - which I’m ok with. But when it lists what it has scanned:

17:09:48.522 INFO: 4 source files to be analyzed
17:09:48.526 DEBUG: 'Web.Debug.config' generated metadata with charset 'UTF-8'
17:09:48.740 DEBUG: Count lines in file:///E:/Users/xxxxx/Git/WS-DocServices/DocServices-WebApp/Web.Debug.config
17:09:48.840 DEBUG: 'packages.config' generated metadata with charset 'UTF-8'
17:09:48.844 DEBUG: Count lines in file:///E:/Users/xxxxx/Git/WS-DocServices/DocServices-WebApp/packages.config
17:09:48.867 DEBUG: 'Web.Release.config' generated metadata with charset 'UTF-8'
17:09:48.870 DEBUG: Count lines in file:///E:/Users/xxxxx/Git/WS-DocServices/DocServices-WebApp/Web.Release.config
17:09:48.910 DEBUG: 'Web.config' generated metadata with charset 'UTF-8'
17:09:48.922 DEBUG: Count lines in file:///E:/Users/xxxxx/Git/WS-DocServices/DocServices-WebApp/Web.config
17:09:48.999 INFO: 4/4 source files have been analyzed
17:09:49.000 INFO: Sensor XML Sensor [xml] (done) | time=488ms
17:09:49.000 INFO: Sensor JaCoCo XML Report Importer [jacoco]
17:09:49.002 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
17:09:49.004 INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
17:09:49.004 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
17:09:49.004 INFO: Sensor IaC Docker Sensor [iac]
17:09:49.013 INFO: 0 source files to be analyzed
17:09:49.165 INFO: 0/0 source files have been analyzed

It’s only the web config files, none of the actual source.

This isn’t the entire console log. And I have chopped bits out of it, where I think the relevant bits are.

Hey there.

I think you’ll need to share the full logs, ideally of the SonarScanner for .NET begin step (set sonar.verbose=true for good measure), the build, and the end step.

I have them here zipped up. No tthe same project, but it has exactly the same problem. A Dot Net Web Site where a new project has been made as a web application, so that it can be compiled and scanned with Sonar scanner for Dot net Framework.
sonar.zip (18.5 KB)

The files all list, but have no lines of code. and no issues, and even when I introduce an issue (hard coded DB connection string) it doesn’t seem to pick it up.

I’ve tried all sorts of options for adding source, excluding test projects everything. My regular windows console and windows forms projects with test projects scan fine. It’s just these web application ones I can’t get to find anything.

Hey there,

Could you try a new scan while setting /d:sonar.scanner.scanAll=false in the begin step and let me know if the problem still occurs?
It would be very helpful in debugging the problem.
Thanks in advance!

I couldn’t see that making any difference.

I’d added some rulesets etc to the build command: /p:RunCodeAnalysis=true;CodeAnalysisRuleSet=E:\Users\psyciknz\Git\WS-AdminServices\App\App.ruleset /p:CollectCoverage=True /p:CoverletOutputFormat=opencover

And can see that they are picking up 75 warning as part of the build.

I also saw these messages

07:36:57.652 DEBUG: File App/App_Code/SecureToken/TokenServiceImpl.cs excluded for duplication
07:36:57.652 DEBUG: 'App\App_Code\SecureToken\TokenSigner.cs' indexed with language 'cs'
07:36:57.652 DEBUG: File App/App_Code/SecureToken/TokenSigner.cs excluded for duplication
07:36:57.653 DEBUG: 'App\App_Code\SecureToken\TokenVerifier.cs' indexed with language 'cs'
07:36:57.653 DEBUG: File App/App_Code/SecureToken/TokenVerifier.cs excluded for duplication
07:36:57.653 DEBUG: 'App\App_Code\SecureToken\Exception\ServiceException.cs' indexed with language 'cs'
07:36:57.653 DEBUG: File App/App_Code/SecureToken/Exception/ServiceException.cs excluded for duplication

sonar.zip (27.4 KB)

Hey there,

Could you please elaborate on what you mean by “convert to Web App”?
What was the type of the project before and what is it after?
What changes did you do during the migration?

Also, could you by any chance try running the scanner locally against the project, to make sure there is no weird behavior with the pipeline?
From the logs it seems like we find two projects:

  • Testing.csproj, marked as test code.
  • App.csproj, marked as production code.

…and for some reason, even though our analyzers in the begin step seem to be properly injected, we do not see any issues raised for App.csproj during the build.

I only see one issue, in test code, to be exact:

...Testing\LogonTests.cs(60,13): warning S2925: Do not use 'Thread.Sleep()' in a test. [...\Testing\Testing.csproj]

…which means that our analyzers are there and running, but for some reason not reporting any issues.

Another thing that would be useful to share, is your .sonarqube\conf\SonarQubeAnalysisConfig.xml file, which is generated after the begin step. If you could print it during the CI run and paste it here, it would be very helpful.

Project was a wev site project which I understood to not be compatible with so art scanner.

So I added a web application project. And manually codes all of the code files due as unsung linked files it complained the source it not there.

I’ll get the config. But that issue you found shouldn’t even be covered as the testing project if adddd to the csproj that it was to be excluded.

Oh. This is all local. I am performing the scanning on the local code that visual studio uses. There is no CI pipeline.

Config
SonarQubeAnalysisConfig.zip (3.2 KB)

Hey there,
Looking at your configuration, everything seems normal to me.
Could you also send me the csproj of your project, as well as the ruleset you said you specified on the build command?

From what I see, this is probably a configuration issue, as our plugins are loaded and the files are picked up and indexed.
It seems like the rules are not running, so it’s either the ruleset or the project is not eligible.

Also, it would be great if you had a small reproducer of this behavior with a web project, either on github or as a zip.

Thanks in advance and sorry for the delay :slight_smile:

1 Like

Hi. Thanks for your continued support

I should be able to do that in a day or so.

Are you ok for me to message you directly with a project? Etc. Rather than post publicly

After discussing this privately, the problem was coming from files not being referenced by the build system.
Before they were added to the csproj like this:

 <ItemGroup>
    <Content Include="File.cs" />
  </ItemGroup>

And the fix was to add them as compilation units:

 <ItemGroup>
    <Compile Include="File.cs" />
  </ItemGroup>

Cheers!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.