New Msbuild Sonar runner is skipping analysis for .net projects

浪尽此生 提交于 2019-12-08 04:25:56

问题


I have setup new Msbuild sonar runner and kickoff analysis for a project type "class library". It went successful. To test it further,

  1. I have created one more project which has only one file with 5 Interface definitions.
  2. I made sure that names of interfaces NOT started with letter 'i'.
  3. I created a quality profile with one stylecop rule i.e. "Interface names must begin with i".
  4. I started cmd prompt (VS command prompt) and change it's path to the directory which has .csproj file. Clearly I am NOT at .sln file level. precisely one more level down where we can see .csproj file.
  5. Fired Begin - msbuild -end sequence.
  6. It shows ANALYSIS SUCCESSFUL but when I don't see any issues on dashboard ( Issues zero where as I expect 5, each one is for one interface).
  7. After careful observation of Log, It shows following message. I am not sure that I quite understand it.

WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\raja.moparthi\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.cs, project: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\TestFib2.csproj

Please let me know what is going wrong here.

Begin command Log given below :

Default properties file was found at D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml

Loading analysis properties from D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml

Pre-processing started.

Using environment variables to determine the download directory...

Removing the existing directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube

Creating directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube

Creating directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin

SonarQube server url: http://{SonarQube ServerName: I removed it}:9000/

Downloading SonarQube.MSBuild.Runner.Implementation.zip from http://{SonarQube ServerName: I removed it}/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip to D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\SonarQube.MSBuild.Runner.Implementation.zip






Executing file D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\MSBuild.SonarQube.Internal.PreProcess.exe

  Args: "/k:FibTest" "/n:FibTestAnalysis" "/v:1.0.0.0" "/s:D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml"


  Working directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube


  Timeout (ms):-1


  Process id: 4692


10:51:21 PM  Loading analysis properties from D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml


10:51:21 PM  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\raja.moparthi\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore

10:51:21 PM  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\raja.moparthi\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore

10:51:21 PM  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\raja.moparthi\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore


10:51:21 PM  Not running under TeamBuild

10:51:21 PM  Analysis base directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube

Build directory: 
Bin directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin


Config directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf

Output directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out


Config file: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out

10:51:21 PM  Creating config and output folders...

10:51:21 PM  Creating directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf

10:51:21 PM  Creating directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out

10:51:21 PM  Generating the FxCop ruleset: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf\SonarQubeFxCop-cs.ruleset


10:51:22 PM  Generating the FxCop ruleset: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf\SonarQubeFxCop-vbnet.ruleset


10:51:22 PM  Saving the config file to D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf\SonarQubeAnalysisConfig.xml


Process returned exit code 0


Pre-processing succeeded.

----------------
Msbuild command log is given below.

Microsoft (R) Build Engine version 12.0.21005.1
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 9/8/2015 10:51:36 PM.

Project "D:\SonarQube-Test-Projects\Fibanocci\TestFib2\TestFib2.csproj" on node 1 (default targets).


GenerateTargetFrameworkMonikerAttribute:

Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.

CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.

_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.


CopyFilesToOutputDirectory:
  TestFib2 -> D:\SonarQube-Test-Projects\Fibanocci\TestFib2\bin\Debug\TestFib2.exe


OverrideCodeAnalysisProperties:
  Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: D:\SonarQube-Test-Projects\Fibanocci


\TestFib2\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset
  Skipping FxCop analysis: the project is a test project

SetStyleCopAnalysisSettings:
  Setting 'sonar.stylecop.projectFilePath' to 'D:\SonarQube-Test-Projects\Fibanocci\TestFib2\TestFib2.csproj'


WriteSonarQubeProjectData:
  Directory "D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\\TestFib2__AnyCPU_Debug_635773494965392474" doesn't exist. Skipping.


  Creating directory "D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\\TestFib2__AnyCPU_Debug_635773494965392474".

Done Building Project "D:\SonarQube-Test-Projects\Fibanocci\TestFib2\TestFib2.csproj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.32
End

----------------
End command log is given below.

Default properties file was found at D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml

Loading analysis properties from D:\MsBuildSonarQubeRunner\SonarQube.Analysis.xml

Post-processing started.

Using environment variables to determine the download directory...

Executing file D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\MSBuild.SonarQube.Internal.PostProcess.exe

  Args: 
  Working directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube
  Timeout (ms):-1
  Process id: 8528

10:51:54 PM  Not running under TeamBuild

10:51:54 PM  Analysis base directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube

Build directory: 

Bin directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin

Config directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf

Output directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out

Config file: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out

10:51:54 PM  Loading the SonarQube analysis config from D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\conf\SonarQubeAnalysisConfig.xml

10:51:54 PM  Generating SonarQube project properties file to D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\sonar-project.properties

10:51:54 PM  WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\raja.moparthi\AppData\Local\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs, project: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\TestFib2.csproj


10:51:54 PM  Writing processing summary to D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\ProjectInfo.log

10:51:54 PM  Creating directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\sonar-runner

10:51:54 PM  The SONAR_RUNNER_HOME environment variable is not required and will be ignored.

10:51:54 PM  Calling the sonar-runner...

10:51:54 PM  SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024m

10:51:54 PM  Setting environment variable 'SONAR_RUNNER_OPTS'. Value: -Xmx1024m

10:51:54 PM  Executing file D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\sonar-runner\bin\sonar-runner.bat


  Args: -Dproject.settings="D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\sonar-project.properties"

  Working directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\sonar-runner\bin
  Timeout (ms):-1
  Process id: 11196


10:51:54 PM  D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\sonar-runner\bin\..

10:51:54 PM  SonarQube Runner 2.4

10:51:54 PM  Java 1.8.0_60 Oracle Corporation (64-bit)

10:51:54 PM  Windows 7 6.1 amd64

10:51:54 PM  SONAR_RUNNER_OPTS=-Xmx1024m

10:51:54 PM  INFO: Runner configuration file: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties

10:51:54 PM  INFO: Project configuration file: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\sonar-project.properties

10:51:54 PM  INFO: Default locale: "en_US", source code encoding: "UTF-8"

10:51:54 PM  INFO: Work directory: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\.sonar

10:51:55 PM  INFO: SonarQube Server 5.0.1

10:51:56 PM  22:51:56.238 INFO  - Load global referentials...

10:51:57 PM  22:51:57.049 INFO  - Load global referentials done: 813 ms

10:51:57 PM  22:51:57.055 INFO  - User cache: C:\Users\raja.moparthi\.sonar\cache

10:51:57 PM  22:51:57.065 INFO  - Install plugins

10:51:57 PM  22:51:57.390 INFO  - Install JDBC driver

10:51:57 PM  22:51:57.600 INFO  - Create JDBC datasource for jdbc:jtds:sqlserver://{DB server- I removed original server name for security purpose}/sonar;SelectMethod=Cursor


10:52:04 PM  22:52:04.530 INFO  - Initializing Hibernate

10:52:07 PM  22:52:07.162 INFO  - Load project referentials...

10:52:10 PM  22:52:10.353 INFO  - Load project referentials done: 3191 ms

10:52:10 PM  22:52:10.354 INFO  - Load project settings

10:52:10 PM  22:52:10.884 INFO  - Loading technical debt model...

10:52:11 PM  22:52:11.930 INFO  - Loading technical debt model done: 1046 ms

10:52:11 PM  22:52:11.936 INFO  - Apply project exclusions

10:52:20 PM  22:52:20.949 WARN  - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.


10:52:20 PM  22:52:20.951 INFO  - -------------  Scan TestFib2

10:52:20 PM  22:52:20.955 INFO  - Load module settings

10:52:57 PM  22:52:57.308 INFO  - Loading rules...

10:53:07 PM  22:53:07.904 INFO  - Loading rules done: 10596 ms

10:53:08 PM  22:53:08.100 INFO  - Configure Maven plugins

10:53:10 PM  22:53:10.219 INFO  - Compare to previous analysis (2015-09-08)

10:53:10 PM  22:53:10.439 INFO  - Compare over 30 days (2015-08-09, analysis of 2015-09-08 21:09:01.457)

10:53:10 PM  22:53:10.441 INFO  - No quality gate is configured.

10:53:10 PM  22:53:10.513 INFO  - Base dir: D:\SonarQube-Test-Projects\Fibanocci\TestFib2

10:53:10 PM  22:53:10.514 INFO  - Working dir: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\.sonar\FibTest_FibTest_B51D1FBF-8925-45C4-B8C8-5DBE2F60DBCE


10:53:10 PM  22:53:10.518 INFO  - Test paths: Program.cs, Properties/AssemblyInfo.cs, App.config


10:53:10 PM  22:53:10.519 INFO  - Source encoding: UTF-8, default locale: en_US

10:53:10 PM  22:53:10.519 INFO  - Index files

10:53:10 PM  22:53:10.576 INFO  - 2 files indexed

10:53:15 PM  22:53:15.923 INFO  - Quality profile for cs: Mks Test Rules

10:53:15 PM  22:53:15.949 INFO  - Sensor QProfileSensor...

10:53:15 PM  22:53:15.961 INFO  - Sensor QProfileSensor done: 12 ms

10:53:15 PM  22:53:15.961 INFO  - Sensor InitialOpenIssuesSensor...

10:53:17 PM  22:53:17.547 INFO  - Sensor InitialOpenIssuesSensor done: 1586 ms

10:53:17 PM  22:53:17.548 INFO  - Sensor ProjectLinksSensor...

10:53:18 PM  22:53:18.541 INFO  - Sensor ProjectLinksSensor done: 993 ms

10:53:19 PM  22:53:19.130 INFO  - Sensor VersionEventsSensor...

10:53:21 PM  22:53:21.896 INFO  - Sensor VersionEventsSensor done: 2766 ms

10:53:21 PM  22:53:21.896 INFO  - Sensor FileHashSensor...

10:53:21 PM  22:53:21.904 INFO  - Sensor FileHashSensor done: 8 ms

10:53:21 PM  22:53:21.904 INFO  - Sensor SCM Sensor...

10:53:21 PM  22:53:21.904 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.

10:53:21 PM  22:53:21.904 INFO  - Sensor SCM Sensor done: 0 ms

10:53:21 PM  22:53:21.904 INFO  - Sensor CPD Sensor...

10:53:21 PM  22:53:21.905 INFO  - DefaultCpdEngine is used for cs

10:53:21 PM  22:53:21.906 INFO  - Sensor CPD Sensor done: 2 ms

10:53:22 PM  22:53:22.118 INFO  - Execute decorators...

10:53:28 PM  22:53:28.033 INFO  - -------------  Scan FibTestAnalysis

10:53:28 PM  22:53:28.039 INFO  - Load module settings

10:53:28 PM  22:53:28.086 INFO  - Configure Maven plugins

10:53:28 PM  22:53:28.291 INFO  - Compare to previous analysis (2015-09-08)

10:53:28 PM  22:53:28.491 INFO  - Compare over 30 days (2015-08-09, analysis of 2015-09-08 21:09:01.457)

10:53:28 PM  22:53:28.493 INFO  - No quality gate is configured.

10:53:28 PM  22:53:28.518 INFO  - Base dir: D:\SonarQube-Test-Projects\Fibanocci\TestFib2

10:53:28 PM  22:53:28.518 INFO  - Working dir: D:\SonarQube-Test-Projects\Fibanocci\TestFib2\.sonarqube\out\.sonar

10:53:28 PM  22:53:28.518 INFO  - Source encoding: UTF-8, default locale: en_US

10:53:29 PM  22:53:29.121 INFO  - Sensor InitialOpenIssuesSensor...

10:53:30 PM  22:53:30.301 INFO  - Sensor InitialOpenIssuesSensor done: 1180 ms

10:53:30 PM  22:53:30.302 INFO  - Sensor ProjectLinksSensor...

10:53:30 PM  22:53:30.893 INFO  - Sensor ProjectLinksSensor done: 591 ms

10:53:31 PM  22:53:31.483 INFO  - Sensor VersionEventsSensor...

10:53:33 PM  22:53:33.659 INFO  - Sensor VersionEventsSensor done: 2176 ms

10:53:33 PM  22:53:33.659 INFO  - Sensor FileHashSensor...

10:53:33 PM  22:53:33.660 INFO  - Sensor FileHashSensor done: 1 ms

10:53:33 PM  22:53:33.660 INFO  - Sensor SCM Sensor...

10:53:33 PM  22:53:33.660 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.

10:53:33 PM  22:53:33.660 INFO  - Sensor SCM Sensor done: 0 ms

10:53:33 PM  22:53:33.660 INFO  - Sensor CPD Sensor...
10:53:33 PM  22:53:33.660 INFO  - Sensor CPD Sensor done: 0 ms
10:53:33 PM  22:53:33.774 INFO  - Execute decorators...
10:53:37 PM  22:53:37.356 INFO  - Store results in database
10:53:42 PM  22:53:42.464 INFO  - ANALYSIS SUCCESSFUL, you can browse http://{ server- I removed original server name for security purpose}:9000/dashboard/index/FibTest
10:53:42 PM  22:53:42.464 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
10:53:42 PM  22:53:42.465 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
10:53:44 PM  INFO: ------------------------------------------------------------------------
10:53:44 PM  INFO: EXECUTION SUCCESS
10:53:44 PM  INFO: ------------------------------------------------------------------------
10:53:44 PM  Total time: 1:49.413s
10:53:44 PM  Final Memory: 14M/457M
10:53:44 PM  INFO: ------------------------------------------------------------------------
10:53:44 PM  Process returned exit code 0
10:53:44 PM  The sonar-runner has finished
10:53:44 PM  Creating a summary markdown file...
10:53:44 PM  Analysis results: http://{ server- I removed original server name for security purpose}:9000/dashboard/index/FibTest
Process returned exit code 0
Post-processing succeeded.

回答1:


Thanks for providing all these valuable details in your questions, which makes it easier to answer.

First of all, you can safely ignore the message C:\Users\raja.moparthi\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.cs : That file does not belong to your project, and does not have to be analyzed.

Then, I think that you are facing a limitation of the MSBuild SonarQube Runner 1.0 release, which is already fixed in the soon to be released 1.0.1 version: If the full path to your .csproj file contains test, the project will be detected as a test one, and SonarQube doesn't report issues on tests projects. See this tickets for details: https://jira.sonarsource.com/browse/SONARMSBRU-121 While waiting on this new release, the easiest thing you can do is simply to remove test from the folder names.




回答2:


I still have the issue described by Dinesh using TFS' SonarQube Extension 2.0.0, which embeds SonarQube Scanner for MSBuild 2.2.0.24:

If the full path to your .csproj file contains test, the project will be detected as a test one, and SonarQube doesn't report issues on tests projects.

I've solved it by customizing the Test project pattern in Sonar Qube's Administration | Configuration | General Settings | Scanner for MSBuild.



来源:https://stackoverflow.com/questions/32464277/new-msbuild-sonar-runner-is-skipping-analysis-for-net-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!