Sonarscanner.msbuild.exe scans VS2017 projects, but JS and CSS files are not included

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Enterprise edition 9.3

  • what are you trying to achieve
    When the scan is successful, the.js and.css files must be scanned, just like the.cs files.

  • what have you tried so far to achieve this

  1. I scan the project using Sonarscanner instead of Sonarscanner.msbuild.exe, JS and CSS can be scanned.
  2. I checked that the project’s.csproj file, JS and CSS files are contained within the.csproj file’s Content element, and the code block looks like this:
    <Content Include="Scripts\jquery.validate.min.js" />
    <Content Include="Scripts\knockout-2.1.0.debug.js" />
    <Content Include="Scripts\knockout-2.1.0.js" />
    <Content Include="Scripts\modernizr-2.5.3.js" />
    <Content Include="Scripts\mvcfoolproof.unobtrusive.min.js" />
    <Content Include="Scripts\MvcFoolproofJQueryValidation.min.js" />
    <Content Include="Scripts\MvcFoolproofValidation.min.js" />
    <Content Include="Scripts\Common\configuration.js" />
    <Content Include="Scripts\Common\Constants.js" />
    <Content Include="Scripts\Common\customvalidations-1.0.js" />

After scanning with Sonarscanner.msbuild. exe, JS file under Scripts cannot be found under code of Sonarqube project.

Hey there.

I’d suggest passing sonar.verbose=true to the scanner and dig into the logs to discover what files are being indexed, and if any are being excluded from analysis.

Hi Colin,

Thanks for your reply !

I passed sonar.verbose=true to the scanner and Attached is the analysis log.

In the log file,I found as descripition bellow:

14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.projectKey=oss_c_sharp:9582D1F4-F506-4CFC-8C41-D4AE67ADB540
14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.projectName=myreleaseFS.MLP.UI.MVC.Web
14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.projectBaseDir=E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web
14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.sourceEncoding=utf-8
14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.sources=
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Annotations\ATALPHANUM.cs”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Annotations\ATALPHANUMEXTENDED.cs”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Annotations\ATCURRENCYAttribute.cs”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Annotations\ATDATE.cs”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Annotations\ATDECIMAL.cs”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\nps\js\jquery.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\bootstrap-progressbar.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\bootstrap.bundle.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\bootstrap.bundle.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Common\common-1.0.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Common\WChatSessionAlive.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Common\extension.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery-ui.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery-ui.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.idle.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.idle.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.slim.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.slim.min.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\jquery.validate.unobtrusive.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\messages_zh.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ApplicationSubmitted.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ChangeContactInfo.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ChangePaymentAccount.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ChangePaymentAccountOperation.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ChangePaymentAccountSucceed.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ChangePaymentDay.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\CustomDueDateReminderPage.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\CustomizedDueDateReminder.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\DEinput.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\DocumentExchange.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\DocumentUpload.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\EarlyTermination.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\Estatement.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ExclusiveAccount.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\ExclusiveTreatment.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\InputEmail.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\MyActiveDetail.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\OnlinePay.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\OtherMessageReminder.js”,
14:26:55 “E:\jenkins-agent\workspace\Online_Self_Service\DEV\sonarqube_csharp_pipeline\myreleaseFS.MLP.UI.MVC.Web\Scripts\Mymyrelease\pictureDownload.js”,\

14:27:09 14:27:09.973 DEBUG: ‘JavaScript analysis’ skipped because there is no related file in current project

Does this mean that JS files are included, but excluded from project analysis? What should i do with these js file so that they can be analyzed?

sonar.log (6.17 MB)

Hi Colin,

Based on the logs generated by the analysis, can you give us some suggestions?

Thanks

It looks like you’re explicitly excluding Javascript files.

14:26:55 9582D1F4-F506-4CFC-8C41-D4AE67ADB540.sonar.exclusions=**/*.js,**/*.less,**/*.css,**/*.html

So that is probably what you need to fix. Make sure to check the project/instance level Administration > Analysis Scope, or any settings included in a .csproj file.

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