Skip to content

Transactional mode for WriteLinesToFile #12061

@KirillOsenkov

Description

@KirillOsenkov

I have a build where several projects generate the same file in the common output directory using WriteLinesToFile.

Something changed recently and the timing is now such that two projects attempt to write to the same file simultaneously. One project can't open the file for writing because the other project has the file open.

I understand it's not desireable to have double-writes, but I thought that perhaps WriteLinesToFile needs to have a transactional mode.

The Visual Studio editor has this mode already (and it's the default one): when saving a file, first write to a new temp file, then rename the current file to old, then rename the new file to current, then delete the old file. If the rename part fails because the file is locked, you could have retries.

Metadata

Metadata

Labels

Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.help wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions