Skip to content
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

error MSB3491: Could not write lines to file roslyn\artifacts\obj\Microsoft.Build.Tasks.CodeAnalysis\Release\Microsoft.Managed.Core.CurrentVersions.targets because it is being used by another process #45842

Closed
carlossanlop opened this issue Jan 9, 2025 · 5 comments · Fixed by dotnet/roslyn#76701
Labels
Area-NetSDK Known Build Error untriaged Request triage from a team member

Comments

@carlossanlop
Copy link
Member

carlossanlop commented Jan 9, 2025

Build Information

Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=912429&view=logs&j=af161a59-3ba0-595e-b1dd-589f209b7277
Build error leg or test failing: VMR Vertical Build Validation / Windows_DevVersions_x64 / Build
Pull request: #45806

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": ["error MSB3491: Could not write lines to file", "Microsoft.Managed.Core.CurrentVersions.targets"],
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Output:

src\roslyn\src\Compilers\Core\MSBuildTask\Microsoft.Build.Tasks.CodeAnalysis.csproj(111,5): error MSB3491: Could not write lines to file "D:\a\_work\1\vmr\src\roslyn\artifacts\obj\Microsoft.Build.Tasks.CodeAnalysis\Release\Microsoft.Managed.Core.CurrentVersions.targets". The process cannot access the file 'D:\a\_work\1\vmr\src\roslyn\artifacts\obj\Microsoft.Build.Tasks.CodeAnalysis\Release\Microsoft.Managed.Core.CurrentVersions.targets' because it is being used by another process.

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=912429
Error message validated: [error MSB3491: Could not write lines to file Microsoft.Managed.Core.CurrentVersions.targets]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 1/9/2025 10:19:46 PM UTC

Report

Build Definition Step Name Console log Pull Request
912429 dotnet/sdk Build Log #45806

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
1 1 1
@dsplaisted
Copy link
Member

@dotnet/product-construction Can you look at this failure? It seems unrelated to the changes in the corresponding PR.

@ericstj
Copy link
Member

ericstj commented Jan 9, 2025

Seems odd to me that this path is missing a TargetFramework value.

The process cannot access the file 'D:\a_work\1\vmr\src\roslyn\artifacts\obj\Microsoft.Build.Tasks.CodeAnalysis\Release\Microsoft.Managed.Core.CurrentVersions.targets'

That seems like it's bound to have a race condition in a multi-targeted build
https://github.com/dotnet/roslyn/blob/4d3377d96ea29c3d3453ba0d7a0664de071c84ba/src/Compilers/Core/MSBuildTask/Microsoft.Build.Tasks.CodeAnalysis.csproj#L78-L115

Binlog

Reading IntermediateOutputPath from the body of a project in a property group will give you the wrong value, since the targets files which append the TargetFramework (often specified in the project body) to IntermediateOutputPath have not yet been evaluated. I think this project needs to move the setting of CompilerVersionTargetsFileIntermediatePath into a Target or as an item so that it gets the correct value of IntermediateOutputPath.

@jaredpar

@jaredpar
Copy link
Member

jaredpar commented Jan 9, 2025

Hmm ... how can we make this work then?

  <Target Name="GenerateCompilerVersionTargetsFile"
          Outputs="$(CompilerVersionTargetsFileIntermediatePath)">

Part of the reason it's set outside the target is so that we can have a proper Outputs entry for the target.

@ericstj
Copy link
Member

ericstj commented Jan 9, 2025

Outputs without inputs doesn't do what you think. It still regenerates this every time.
Image

Using an item worked without much refactoring. I'll put up a PR.

Also, it looks like binlog's double write detection doesn't catch WriteLinesToFile. Seems like a feature we can add there too.

@jaredpar
Copy link
Member

jaredpar commented Jan 9, 2025

Also, it looks like binlog's double write detection doesn't catch WriteLinesToFile. Seems like a feature we can add there too.

I was looking at that too. I suspect it's because the option WriteOnlyWhenDifferent muddies the water here a bit. In build where WriteLinesToFile was called serially with that set to true it's possibly correct. My preference would be that double write flag that usage.

Is there a case we're missing here @rainersigwald where this can be used correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK Known Build Error untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants