-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SonarQube.Integration.ImportBefore.targets removal by TargetsUninstaller causes issues with Concurrent Analysis #843
Comments
Hi, This scenario is not supported by default, however, have you followed the workaround proposed here ? (In the Advanced topics part) https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/ Thanks. |
Hi Mickael, I will have another look at following the instructions and report if we still run into issues (although I thought we already did that). However, I noted there is a little bit of outdated/incorrect information in the docs you linked:
|
@mickael-caro-sonarsource , unfortunately even with the instruction of copying files to the global VS ImportBefore folder, This causes MSBuild to actually look for and import also the per-user ImportBefore file. We see this issue occurring at least once a week across a range of builds on our servers. |
Thanks @japj , we'll have a look at that. |
@mickael-caro-sonarsource hope you are all ok. |
The workaround is not really good because:
(notice that I don't get the error reported by japj "The process cannot access the file 'C:\Users<username>\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets' because it is being used by another process" but the error I get is fully reproducible with two .bat files with PAUSE statements after each command.
|
Try the following approach:
This approach:
|
@cjquintero unfortunately, your workaround does not solve the problem we are having with the The problem is that the SonarScanner.MSBuild.exe will still copy and remove files in the global importbefore folders where MSBuild will pick them up (regardless if whether CustomBeforeMicrosoftCSharpTargets is set). The ImportBefore folders are actually handled by Microsoft.Common.props and the CustomBeforeMicrosoftCSharpTargets is handled by Microsoft.CSharp.targets |
@japj Yes, but SonarScanner.MSBuild.exe copies and remove the files in different phases: they are copied in the "begin" phase and are removed in the "end" phase. In between, you have two chances of removing them in your build (steps 2 and 4 of my list) handling the error "The process cannot access the file", for example, with retries. If you manage to delete the files before the step 5 of my list, when the "end" phase of the SonarScanner.MSBuild.exe is going to delete them they no longer exist. The difference is that you can control the exception deleting the file and retry a number of times until it succeeds. That said, I have never seen the error "The process cannot access the file" (maybe because I don't have "lots" of concurrent builds) but I have suffered a concurrency problem ("SonarQube was unable to collect the required information about your projects") with two simultaneous Jenkins builds (that I explained above) and I managed to solve it with my workaround. And finally, I think you can disable the use of "%USERPROFILE%\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore", so although SonarScanner.MSBuild.exe copies/deletes files there, MSBuild doesn't use them, minimizing the chances of "access denied". This could be done as explained here: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build ("MSBuildExtensionsPath and MSBuildUserExtensionsPath" section). |
@mickael-caro-sonarsource great news! can't wait to rollout, do you have any e.t.a. on the 5.1.0 release? |
Hello, (Or is the workaround still required? https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/ does not seem to have been updated but I'm not sure it's on purpose) EDIT: Ok, so I went ahead and tested this, and it looks like the Correct me if I'm wrong, but it looks like concurrent builds are not a problem anymore (at the price of targets files always remaining on the build machine), and https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/ should be updated accordingly. |
You're right @mlaily thanks for the heads up. |
Description
In a situation with concurrent analysis on the same build machine, the TargetUninstaller will always remove the SonarQube.Integration.ImportBefore.targets from its installation folder, causing issues with "file in use".
Repro steps
Expected behavior
In a concurrent analysis environment, TargetUninstaller should NOT uninstall the SonarQube.Integration.ImportBefore.targets
Actual behavior
Known workarounds
none
Related information
The text was updated successfully, but these errors were encountered: