-
Notifications
You must be signed in to change notification settings - Fork 143
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
MoveDirectory fails intermittently (Razor projects) #1123
Comments
Just adding that we're currently experience this issue in AzDO with the following;
We see this at both lines 418 and 404 of SonarQube.Integration.targets: with the final message
|
|
@duncanp-sonar my naive approach to reproduce was to re-do the analysis multiple times on the same build machine (in case there was a problem with clean-up). I wasn't able to reproduce although I tried with various NET 5 web apps (see here and squidex). |
I do, shared with @fan-yang-sonarsource and @joe-tingsanchali-sonarsource - but I can add you directly as well.
We use a mix in our ADO
Intermittently, about 10% of the time from the statistics we currently have.
This is different across projects, but for the one I was able to reproduce we are using MSBuild .NET core v3.1.416. I'm not sure how to tell exactly which plugin version we're using, but it should be latest provided by ADO. We're using these step task templates; SonarQubePrepare@4, SonarQubeAnalyze@4, SonarQubePublish@4. Is there a way to get more detailed info on this? @andrei-epure-sonarsource - responses in-line. You can also check your internal jira service desk ticket SUPPORT-28422 for a full log/yaml dump. |
@grpatter I will reach out to @andrei-epure-sonarsource and be synced with him. |
Thanks a lot @grpatter for creating this reproducer. You are awesome. I was able to reproduce the problem after running the build 6 times on it. The problem is a race condition created when the folder There are possible fixes:
IMO the second option is better. I will present the timeline from the reproducer. For brevity I removed the The first project (
The second project (
And the first project will finish the move
The race happens somewhere between And the second project fails because
|
Description
See this community thread: https://community.sonarsource.com/t/error-msb4018-the-movedirectory-task-failed-unexpectedly-system-io-ioexception-cannot-create-a-file-when-that-file-already-exists/52100
The underlying cause is not clear. The error occurs intermittently when processing projects that have Razor files.
The error occurs on a self-hosted build agent (-> perhaps the files are not being cleaned up correctly between runs?)
Repro steps
See the community thread.
Expected behavior
Analysis succeeds.
Actual behavior
IO exceptions occur intermittently.
Notes
Razor projects call the compiler twice: the first to compile the "normal" source, the second to compile the Razor source.
The processing does the following (TODO - confirm):
We don't need to do all of this copying about - the directory names are internal, so we could get away with just renaming the original "source" analysis directory.
See also #1063. The errors are in our custom task, which could be replaced by standard MSBuild tasks (although that might not fix this current issue).
Call stack
Note: there are two separate errors on two different projects in the log excerpt below:
##[error]C:\tfs\Agent\_work\3\.sonarqube\bin\targets\SonarQube.Integration.targets(418,5): Error MSB4018: The "MoveDirectory" task failed unexpectedly. System.IO.IOException: Cannot create a file when that file already exists.
This occurs in
SonarFinishRazorProjectCodeAnalysis
when trying to move the "source" analysis files back to the original location.and
##[error]C:\tfs\Agent\_work\3\.sonarqube\bin\targets\SonarQube.Integration.targets(404,5): Error : The destination directory is invalid.
This occurs in
SonarPrepareRazorProjectCodeAnalysis
when trying to move the "source" analysis output to a temporary directory.Looking at the code, the error seems to indicate that the temporary directory already exists.
##[error]C:\tfs\Agent_work\3.sonarqube\bin\targets\SonarQube.Integration.targets
Known workarounds
None.
Related information
The text was updated successfully, but these errors were encountered: