SonarQube parallel builds: System.IO.IOException: The file SonarQube.Integration.ImportBefore.targets already exists

537 Views Asked by At

When running multiple different or parallel jobs in Jenkins that involve the SonarQube Scanner for MSBuild, this exception immediately terminates the build job:

10:46:22 [workspace] $ C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656
\MSBuild.SonarQube.Runner.exe begin /k:auth-services /n:auth-services /v:develop-b82 /d:sonar.host.url=http://redacted:9000 /d:sonar.cs.vscoveragexml.reportsPaths=C:\Jenkins\auth-services\auth-services-develop\workspace\VisualStudio.coveragexml /d:sonar.exclusions=node_modules/**,**/*.js
10:46:23 SonarQube Scanner for MSBuild 3.0.2
10:46:23 Default properties file was found at C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656\SonarQube.Analysis.xml
10:46:23 Loading analysis properties from C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656\SonarQube.Analysis.xml
10:46:23 Pre-processing started.
10:46:23 Preparing working directories...
10:46:23 10:46:23.814  Updating build integration targets...
10:46:23 
10:46:23 Unhandled Exception: System.IO.IOException: The file 'C:\Users\serviceaccount\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets' already exists.
10:46:23    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
10:46:23    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
10:46:23    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.CopyIfDifferent(String sourcePath, IEnumerable`1 destinationDirs, ILogger logger)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.InternalCopyTargetsFile(ILogger logger)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.InstallLoaderTargets(ILogger logger, String workDirectory)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.InstallLoaderTargets(ProcessedArgs args)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.Execute(String[] args)
10:46:23    at SonarQube.Bootstrapper.BootstrapperClass.PreProcess()
10:46:23    at SonarQube.Bootstrapper.BootstrapperClass.Execute()
10:46:23    at SonarQube.Bootstrapper.Program.Execute(String[] args, ILogger logger)
10:46:23    at SonarQube.Bootstrapper.Program.Main(String[] args)
10:46:23    at SonarQube.Old.Bootstrapper.Program.Main(String[] args)
10:46:26 ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 255)

Restarting the build job while no other jobs involving the scanner are running seems to successfully finish building.

0

There are 0 best solutions below