When using SonarQubePrepare@5 buildstep in an Azure DevOps Server yaml pipeline definition the SonarQube scanner will ignore the projectBaseDir property when using the MSBuild scanner and seems to always assume Build.SourcesDirectory or System.DefaultWorkingDirectory (not sure since both are always the same). This might be ok for most scenarios, but with Microsoft build agent 3.231 there’ll be a new feature that allows you to check out repositories anywhere below the Agent.WorkFolder directory. This is so you can use centralized repositories that save a lot of space with multiple pipelines on self hosted agents. But when you check them out the a directory like say “C:\agent_work\Repositories\MyRepo” instead of “C:\agent_work\1\s” this won’t work since Microsoft doesn’t adapt the Build.SourcesDirectory or System.DefaultWorkingDirectory variables accordingly. Which means just assuming those variables are correct does no longer work in those scenarios since none of the source files will be below the “base directory” of “C:\agent_work\1\s”.
What we need here is the possibility to set the projecteBaseDir for MSBuild scanner projects to something different from the default, or else this feature cannot be used with SonarQube.
See this pull request here with which this feature was pulled into the agent master branch and where I’m again mentioning the problem with the SonarQube build step: https://github.com/microsoft/azure-pipelines-agent/pull/4423#issuecomment-1777446426
I’ve also already opened an issue here once about this, before the feature was in the agent. So I’m opening a new issue here so you know it’s kinda urgent now. Here’s the link to the old issue: Ability to set working directory for MSBuild Sonar Scanner in Azure DevOps Server extension