Skip to content

Fix MSBuild race condition in StartupHook build reference#8976

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-race-condition-in-build
Draft

Fix MSBuild race condition in StartupHook build reference#8976
Copilot wants to merge 2 commits intomainfrom
copilot/fix-race-condition-in-build

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

Summary

Parallel builds were hitting a file access race condition on Microsoft.Diagnostics.Monitoring.StartupHook.dll. Added OutputItemType="" and SkipGetTargetFrameworkProperties="true" to the ProjectReference with Targets="Publish" to prevent MSBuild from creating cross-project dependencies that cause simultaneous file access. Additionally, explicitly set TargetFramework=$(StartupHookTargetFramework) in AdditionalProperties to ensure proper target framework resolution when using SkipGetTargetFrameworkProperties="true".

Release Notes Entry
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix known race condition in build</issue_title>
<issue_description>#8555 (comment)</issue_description>

Comments on the Issue (you are @copilot in this section)

@wiktork ##[error]CSC(0,0): error CS2012: (NETCORE_ENGINEERING_TELEMETRY=Build) Cannot open 'D:\a\_work\1\s\artifacts\obj\Microsoft.Diagnostics.Monitoring.StartupHook\Release\net6.0\Microsoft.Diagnostics.Monitoring.StartupHook.dll' for writing -- The process cannot access the file 'D:\a\_work\1\s\artifacts\obj\Microsoft.Diagnostics.Monitoring.StartupHook\Release\net6.0\Microsoft.Diagnostics.Monitoring.StartupHook.dll' because it is being used by another process.; file may be locked by 'csc' (2012)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix known race condition in build process Fix MSBuild race condition in StartupHook build reference Feb 18, 2026
Copilot AI requested a review from wiktork February 18, 2026 19:59
Copilot AI and others added 2 commits February 24, 2026 17:06
Add OutputItemType="" and SkipGetTargetFrameworkProperties="true" to the ProjectReference for Microsoft.Diagnostics.Monitoring.StartupHook in dotnet-monitor.csproj. This prevents parallel build race conditions where multiple processes try to access the StartupHook.dll file simultaneously.

Fixes #8555

Co-authored-by: wiktork <15879456+wiktork@users.noreply.github.com>
When using SkipGetTargetFrameworkProperties="true", we need to explicitly specify the TargetFramework in AdditionalProperties to avoid target framework resolution errors. This ensures the StartupHook is built with net6.0 as expected.

Addresses feedback from @wiktork

Co-authored-by: wiktork <15879456+wiktork@users.noreply.github.com>
@wiktork wiktork force-pushed the copilot/fix-race-condition-in-build branch from dc8ba1e to 1c1c2eb Compare February 25, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix known race condition in build

2 participants