Concurrent analysis of .net code fails intermittently

dotnet

(Peter Kristiansen) #1

versions used

  • SonarQube 6.7.4
  • TFS 2017 Update 3
  • TFS SonarQube plugin 4.5.1

error observed
Concurrent analysis of .net code fails intermittently. A while ago we found that concurrent analysis of .net builds failed on our build servers. We found this https://docs.sonarqube.org/display/SCAN/Miscellaneous+Advanced+Usages page and followed the instructions as given, which worked. The last couple of weeks we have started seeing this error:

2018-12-14T02:00:47.4746077Z ##[error]Unhandled Exception:
2018-12-14T02:00:47.4902338Z ##[error]System.IO.IOException: The file 'C:\Users\username\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets' already exists.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at SonarScanner.MSBuild.PreProcessor.TargetsInstaller.CopyIfDifferent(String sourcePath, IEnumerable`1 destinationDirs)
   at SonarScanner.MSBuild.PreProcessor.TargetsInstaller.InstallLoaderTargets(String workDirectory)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
   at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
   at SonarScanner.MSBuild.BootstrapperClass.Execute()
   at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
   at SonarScanner.MSBuild.Program.Main(String[] args)
2018-12-14T02:00:47.4902338Z System.IO.IOException: The file 'C:\Users\username\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets' already exists.
2018-12-14T02:00:47.4902338Z    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
2018-12-14T02:00:47.4902338Z    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.PreProcessor.TargetsInstaller.CopyIfDifferent(String sourcePath, IEnumerable`1 destinationDirs)
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.PreProcessor.TargetsInstaller.InstallLoaderTargets(String workDirectory)
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.BootstrapperClass.Execute()
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
2018-12-14T02:00:47.4902338Z    at SonarScanner.MSBuild.Program.Main(String[] args)
2018-12-14T02:00:47.4902338Z ##[error]E:\T\b1\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.5.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 3762504530

A search for that error gave us this https://github.com/SonarSource/sonar-scanner-msbuild/issues/550 which seems to be a similar issue for Gitlab CI.

steps to reproduce
Start multiple analysis of .net code concurrent.

potential workaround

  • None implemented.
  • We could reduce the number of build agents available for .net builds to one pr. server.
  • We could create a number of new service accounts such that each TFS build agent runs with a separate account.

(Valeri Hristov) #2

Hi @PeterKristiansen,

Thanks for the feedback. I created a ticket to track the progress of this bug:

For concurrent analysis we usually recommend using different user accounts for the build agents that are configured on the same machine and I think this is the best way to workaround the problem. If you have large build machines with a lot of processing power it does not make much sense to reduce the number of agents…


(Peter Kristiansen) #3

Hi,

Yes, we are aware of the workaround. But in my opinion it is closer to an error. Are there any plans to fix this issue?

br
Peter