Skip to content

CI build intermittently fails on Windows with file locks in obj\Release\*\*.GeneratedMSBuildEditorConfig.editorconfig and CS2012 #56

@jeffpatton1971

Description

@jeffpatton1971

Summary
On windows-latest, dotnet build intermittently fails with file locking errors in src\Xml2Doc.Core\obj\Release\{tfm}\...GeneratedMSBuildEditorConfig.editorconfig and/or CS2012 failing to write obj\Release\{tfm}\Xml2Doc.Core.dll.

Environment

  • Runner: windows-latest
  • Build command: dotnet build ... --configuration Release --no-restore
  • Observed SDK: 10.0.100 (from build output)

Steps to Reproduce

  1. Run Merge Test Workflow on a PR targeting main.
  2. dotnet clean
  3. dotnet restore
  4. dotnet build ... --configuration Release --no-restore

Expected
Build completes successfully.

Actual
Build fails with errors like:

  • Microsoft.Managed.Core.targets(...): The process cannot access ...GeneratedMSBuildEditorConfig.editorconfig because it is being used by another process.
  • CSC : error CS2012: Cannot open ...obj\Release\net9.0\Xml2Doc.Core.dll for writing -- The process cannot access the file because it is being used by another process. ([Microsoft Learn][2])

Notes / suspected cause
This appears to be a Windows file-handle contention issue involving Roslyn/MSBuild intermediates and/or compiler/build servers, exacerbated by parallel build behavior.

Proposed fix

  • Disable/flush build servers in CI (dotnet build-server shutdown, --disable-build-servers). ([Microsoft Learn][3])
  • Reduce parallelism for the CI build (-m:1, MSBUILDDISABLENODEREUSE=1). ([GitHub][4])
  • Optionally disable shared compilation in CI (UseSharedCompilation=false) since it defaults to true. ([GitHub][1])

Acceptance criteria

  • CI build and tests pass reliably across repeated runs on windows-latest.
  • No intermittent “file used by another process” failures.

Metadata

Metadata

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions