How can I change the working directory of MSBuild.

2019-09-16 18:29发布

问题:

We are currently calling the runner like this:

D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe begin /k:"someKey" /n:"someName" /v:"someVersion" /d:sonar.resharper.cs.reportPath="K:\somePath\resharper.xml"

We want to have the output of sonar in K:\.sonarqube

We tried to use the command line arg /d:sonar.working.directory=K:\\.sonarqube but that didn't work. We also tried setting the working directory in the SonarQube.Analysis.xml like this: <Property Name="sonar.working.directory">K:\.sonarqube\</Property>

That didn't work too ... We need to have it in a top directory, because the sonar runner throws an PathTooLongException (out path is 286 characters long).

Thank you for your help

回答1:

It is not possible to change the working directory of the SonarQube Scanner for MSBuild.

You can however launch the build from another folder, but all 3 steps (begin, msbuild and end) must be launched from that folder:

  1. k:
  2. D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe begin ....
  3. msbuild /t:rebuild c:\whereever\your\sources\are\Solution.sln
  4. D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe end