Ability to set working directory for MSBuild Sonar Scanner in Azure DevOps Server extension

The Sonar Scanner for MSBuild is using the current working directory as the project root directory under which all sources have to be located, but this is a real problem for multiple repositories in the Azure DevOps Server extension, especially for shared repositories, a feature that should soon be implemented into the Microsoft build agents. This would then mean repositories can lie anywhere inside the working directory of the agent, so also outside the pipeline directory under which the sources are currently always located (currently it should always be somewhere below “_work\1\s” but in the future a repository could be located at “_work\ShareRepos\MyRepo”). The SonarQube extension for Azure DevOps Server is currently using the default working directory of the build agent as its own working directory, this works in most cases as long as the sources are located in the default working directory, but we would need this to be adaptable to any other directory to support multiple shared repositories in the future.

Currently the only way to analyse files in multiple shared repositories is to use the standalone scanner and set the sonar.projectBaseDir variable, which is not supported by Sonar Scanner for MSBuild because it uses the working directory. So we would really need this feature to be able to use Sonar Scanner for MSBuild.

I assume it shouldn’t be too hard to do this since its really just about making the working directory of the Sonar Scanner for MSBuild adaptable in the Azure DevOps Server extension.

Hey there.

Do you have a link to some documentation about this new feature in Azure DevOps?

Hi! Yes,
this is the PR to add the ability for shared repositories: Added new agent capability AllowWorkDirectoryRepositories so repositories can be checked out below the work directory level too on self hosted agents by echalone · Pull Request #3475 · microsoft/azure-pipelines-agent · GitHub
this is the PR to add the ability for a working directory different from the default: Added option to use a checkout path of any repository as the default working directory (System.DefaultWorkingDirectory) by echalone · Pull Request #3479 · microsoft/azure-pipelines-agent · GitHub
Here’s the Microsoft employee telling us that we’re in the process of implementing these PRs:
Working directory needs more efficient re-use or cleanup · Issue #1506 · microsoft/azure-pipelines-agent · GitHub