How to include folders projects for sonar analysis which are not part of solution using sonar scanner for .net - sonarqube

How do I configure the sonar to include folders or projects which are not part of the current .net solution. I have the following structure my current project:
MyProject - Root Folder
ProjectA - Normal .net project
ProjectB
MyProject.Services
MyProject.Services - This is a asp.net core project
MyProject.Services.sln
MyProject.Services.Model
MyProject.Services.Repository
MyProject.sln
folder_structure
MyProject.Services is a separate solution having .net core project. During the sonar analysis - it is only analyzing the files associated with MyProject.sln. The requirement is to include files from MyProject.Services as well to have a single report for both solutions.
I tried to include it as a parameter (sonar.sources) but got below error:
File "..." can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
We are using a powershell script for the sonar begin/end step which is getting executed through bamboo build job.
Sonar Scanner:
C:\sonar-scanner-msbuild-4.6.0.1930-net46\SonarScanner.MSBuild.exe
Sonarqube version: 8.9

The Sonar C# and Sonar VB.NET analyzers are Roslyn analyzers, so you need to build a project/solution to get the analysis results. So, if you want issues for MyProject.Services you will have to build it.
You can include the results for multiple MSBuild projects/solutions in the same Sonar project - just build the required projects between the Scanner begin and end steps e.g.
run the scanner begin step
build MyProject.Services.sln
build MyProject.sln
run the scanner end step

Related

How to exclude a project from CICD on Azure DevOps?

I am new to CICD, Azure DevOps. I am trying to implement CICD to Asp .Net Web API project using Azure Devops. I saw few videos on internet and started implementing it. I am done with some standerd CI part but the build is always failing because of one project in a source solution.
So Is there any way to exclude a project from build?
I haven't written .yml file by myself it is auto generated by Azure Devops.
Actually I need a way to exclude a file from .yml file from azure buil pipeline. I tried the following code but still Test.cs is included in build.
trigger:
batch: true
branches:
include:
- master
- QA
paths:
exclude:
- Test/Test.cs
Basically, you can pass the ExcludeFoldersFromDeployment as a parameter to MSBuild. Combining that with the SkipExtraFilesOnServer does the trick.
/p:Configuration=Debug
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=OurDevWebServer/msdeployagentservice
/p:AllowUntrustedCertificate=True
/p:MSDeployPublishMethod=RemoteAgent
/p:CreatePackageOnPublish=True
/p:DeployIisAppPath=umbraco_TestSite
/p:IgnoreDeployManagedRuntimeVersion=True
/p:SkipExtraFilesOnServer=True
/p:ExcludeFoldersFromDeployment="media;App_Data\Logs;App_Data\preview"
/p:IncludeSetAclProviderOnDestination=False
/p:AuthType=NTML /p:UserName=
OR
Use an MS Build project file.
Create an MSBuild project file from scratch
And the at the build solution step in VSTS, select or type the project file path instead of the solution file. You will have to remove it down the road though. The maintenance tasks tend to be hard and counter-intuitive whenever the code base grows quickly. Visual Studio will not warn you if you have build errors (like obsolete path) in the MS Build project file.

SonarQube - Excluding files and folders [Entire .Net Project (csproj)]

I am trying to exclude some folders from Sonar scan through VSTS build. We have used Sonar plugin for MSBuild.
If I use the exclusion pattern as **/*.cs then it is excluding all the .cs files. My goal is to exclude whole folder from scan.
I have tried the following patterns but none of them seems to work
**/folder/*
**/folder/*.cs
**/folder/**
**/folder/**/*
**/folder/**/*.cs
folder/*.cs
folder/**/*.cs
folder/**/*
folder/**
folder/*
Please help in getting the correct pattern.
I want to exclude This Issue project from the scan.
You can exclude an entire C# project by setting the MSBuild property SonarQubeExclude to true in the project file. See this post: How to exclude/ignore referenced project(s) analysis from SoanrQube

No ProjectInfo.xml files were found

i am using visual studio 2015 and tfs for build the project,
I started the build but got stuck with the error described below,
2016-03-17T09:38:15.2135195Z ##[error]No ProjectInfo.xml files were found. Possible causes:
2016-03-17T09:38:15.2135195Z ##[error]1. The project has not been built - the end step was called right after the begin step, without a build step in between
2016-03-17T09:38:15.2135195Z ##[error]2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
2016-03-17T09:38:15.2135195Z ##[error]3. The build step has been launched from a different working folder
2016-03-17T09:38:15.2135195Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2016-03-17T09:38:15.2135195Z 15:08:15.15 Creating a summary markdown file...
2016-03-17T09:38:15.2135195Z ##[error]Post-processing failed. Exit code: 1
2016-03-17T09:38:15.2135195Z ##[error]Unexpected exit code received from batch file: 1
Can any one help me in this?
Assuming you are using TFS2015 vNext build, and you are trying to add build tasks below to execute a SonarQube analysis:
· SonarQube for MSBuild – Begin Analysis
· SonarQube for MSBuild – End Analysis
From your error log, you need to make sure the End Analysis task should be used to create a step that is executed after the “Visual Studio Build” task step. Review blog Build Tasks for SonarQube Analysis get more information of how to use SonarQube analysis tasks.

Sonarqube Analyse source code located in a folder named ".utils"

I am trying to analyse my .NET solution but i can't analyse files (cs files) located in a folder named ".Utils".
The sonar runner seems to skip folders whose name begins with "."
Sample :
- My solution
- Project1
- Context
- Class1.cs
- .Utils
- Class2.cs
Currently, i am able to analyse Class1.cs, but not Class2.cs.
Is it possible to force analyse of this kind of folder ?.
It would be better if I rename it into "Utils", but we have a lot of projects in this case...
Configuration:
SonarQube 5.1
Sonar Runner 2.4
Visual Studio BootStrapper 1.2
C# plugin 4.0
Thank you

Octopack only creating one of two artifacts in TeamCity using Octopus deploy

I have a multiple project solution and am using Octopus Deploy and TeamCity for deployment.
I have installed the Octopack NuGet package on two projects that I wish to be created as artifacts during the CI build.
I have set the follwing in my build step:
and have checked the csproj files of both projects and can see:
<Import Project="..\packages\OctoPack.2.0.26\targets\OctoPack.targets" />
However, after the build runs one of the projects has been packaged as an artifact and the other one hasn't and cant see what the difference between the two is.
Is there something else I should be doing in TeamCity or in my solution?
I had to set the following in configuration manager on the project that wasn't producing the artifact:
Integration|Mixed Platforms.ActiveCfg = Integration|Any CPU
Integration|Mixed Platforms.Build.0 = Integration|Any CPU
Teamcity then happily produced the package.
Make sure you check in the \packages\OctoPack.2.0.26\targets\OctoPack.targets file to your source control.

Resources