Msbuild Sonarqube Runner with multiple build configurations - tfs

We are using TFS to build our projects and for analysis using Sonarqube Msbuild Runner however some of our project are bound to be builded in multiple configurations (Debug|Release) and apparently sonarqube msbuild runner doesn't support multiple configuration.
In the error message (below) suggested analyzing each configuration separately but we don't know how, due the fact that we are just calling runner with begin and end in our TFS xaml build process and everything happens automatically.
Is there a way to analyze both configuration separately or analyzing just one of them?
This is the error message that we are catching in our TFS build report:
No analysable projects were found but some duplicate project IDs were
found. Possible cause: you are building multiple configurations (e.g.
DEBUG|x86 and RELEASE|x64) at the same time, which is not supported by
the SonarQube integration. Please build and analyse each configuration
individually.
Thank you in advance.

You can try to add two pairs of Sonarqube in your build definition and specify the platform and configuration for your project.
Or declare the build variables BuildPlatform and BuildConfiguration on the Variables tab and and reference it here as $(BuildConfiguration). This way you can modify the platform when you queue the build.

Related

How to build only a specific project with DevOps Pipelines

Is this possible to build only a single project and its dependencies specified in a pipeline script?
If I have a Visual Studio Solution with multiple projects, and websites, and I want to build and publish only a specific website and it's dependencies, how could it be done when using DevOps Pipelines, so it does not build the whole solution, but only the required projects for that specific website.
If you want to only build a single project in your solution, you could use the MSBuild task in Azure Devops Pipelines and then point it to the project you want to build.
Another way would be to in your VS solution to edit the Configuration Properties. In the Configuration Manager you can create a Configuration called Single_Project or something like that and then in the properties select which projects to build when using that configuration. Then when you use the VS Build task and specify the configuration you created for your build.

How to build F# projects with Azure Devops Pipelines? I get error 'The target "Build" does not exist in the project'

I'm tinkering with AzureDevops for the first time, to set up some CI tasks.
I have a public repository (opensource) with a solution (.sln) that has 3 F# projects. The solution builds fine in Windows/Mac/Linux.
However, if I try to set up a build pipeline with Azure Devops Pipelines, I get the error:
src\GWallet.Backend\GWallet.Backend.fsproj(0,0): Error MSB4057: The
target "Build" does not exist in the project.
Logs here.
My suspicion is that the build agent that is assigned to execute this doesn't have the F# tooling installed. Because I guess that the target "Build" is defined in the well-known Microsoft.FSharp.Targets file.
How to configure the Windows(VS2017) build agent to install the F# tooling so that this file is discoverable?
#nosami suggested a workaround, which I'm not very happy about (i.e.: I still think AzureDevops team should fix their default hosted agent to include F# tooling), but does the job: use the Microsoft.FSharp.Targets file provided by the nuget package called FSharp.Compiler.Tools. This is the diff in my opensource project if you're curious.
UPDATE: In case the above doesn't help or looks too intricated for you, I think one of this two answers could work: adjusting MSBuild properties of your project or using the proper version of MSBuild could work as well and is simpler.

TFS Build not adding folder to SonarQube

We have introduced SonarQube to our project integrated with TFS Build (2017).
That is our project structure:
SonarQube should run over App, DotNetNuke and LotesKWKPortal
The problem is that Sonar is adding only KWKPortal and LotesKWKPortal, the App folder is ignored:
Is this a problem with the Build definition or with SonarQube?
It seems like Sonar is only analysing folders with .sln files. How do I tell my TFS build to consider all folders in the repository?
EDIT:
That is how our build definition look like:
You're using the SonarQube scanner for MSBuild tasks. Per the docs, you should use the SonarQube CLI task for anything not touched by MSbuild, such as JavaScript.

TFS build template to take the drop (artefacts) from the CI build and execute Integration Tests

I have managed to chain two TFS builds together using Jason Stangroome's chaining build definition template. This gives me the capacity to execute one build definition after the next:
CertificateRepository-CI (Continuous Integration Build)
CertificateRepository-IntegrationTests
The latter will automatically be executed if the former is successful. I am stumped by the lack of Build Definition Templates that are able to download and extract the contents of the preceding build's drop folder and perform actions upon these artifacts, in this case running SpecFlow/NUnit integration tests.
In this case I am using:
Visual Studio Online
Git for the codebase being tested
TFVC for the ALM components (NUnit Adapter, Build Definition Templates)
Any help greatly appreciated.
If you are using TFS for source control: I don't have a template for this but you can follow below steps to achieve this.
In CI build set the Staging Location option to Copy buildoutput to following Source Control folder
Download the drop folder by mapping it in source settings option
in build definition
Under drop location folder in TFS, every CI build will create a new folder, you need to pass this folder name to the second build definition. Please check another post from Jason for passing parameters to second build
Execute the tests by invoking the commandline tools using Invoke
Process activity.

Trying to queue build in TFS server - Calling a target in TFSBuild.Proj

I have been using a msbuild file that builds and packages my solution to 'Client' and 'Server'. So far I have been using the below cmd to build from VS cmd prompt:
msbuild.exe MyBuildFile.proj /t:Build
(I have a target called 'Build' which will kick start build and do the rest).
Now, my team wants to queue builds in TFS build server. I read about TFSBuild.proj file. Should I once again write all the scripts in to TFSBuild.Proj or is there a way by which I can call my 'MyBuildFile.proj /t:Build' from TFSBuild.Proj.
Any help is appreciated.
Thanks, Mani
You can just include your existing MyBuildFile.proj in a TFS 2010 build:
Create a new build definition
In the Process page, choose the UpgradeTemplate.xaml workflow
Select the directory of your checked-in MSBuild.proj file of choice (checked-in under the name TFSBuild.proj)
There might be some subtle differences between your development system and the build server that you need to take care of, but above steps should take you 85%. Enable Diagnostic level build information verbosity (also to be set on the Process page) to troubleshoot loose ends.

Resources