.NET: Foundry.Hosting IT - avoid MSB3026 in publish step#5689
Merged
rogerbarreto merged 3 commits intomainfrom May 7, 2026
Merged
.NET: Foundry.Hosting IT - avoid MSB3026 in publish step#5689rogerbarreto merged 3 commits intomainfrom
rogerbarreto merged 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses intermittent dotnet publish failures (MSB3026 file-in-use) in the Foundry.Hosting integration-test container build by avoiding a second rebuild of referenced libraries when they were already built by the job’s prebuild step.
Changes:
- Updated
it-build-image.ps1to detect prebuilt library outputs and conditionally add-p:BuildProjectReferences=falsetodotnet publish. - Added workflow documentation explaining why the prebuild step exists and why publish is configured to avoid rebuilding project references.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dotnet/tests/Foundry.Hosting.IntegrationTests/scripts/it-build-image.ps1 |
Adds conditional logic to skip ProjectReference rebuild during publish when prebuilt outputs exist. |
.github/workflows/dotnet-build-and-test.yml |
Documents the CI rationale for the publish behavior to prevent MSB3026 collisions. |
247b632 to
0bf21e4
Compare
…flake CI publish step: gate the BuildProjectReferences=false fast-path on an explicit -UsePrebuiltProjectReferences switch (passed by the workflow) instead of marker detection. Adds a preflight error when stale obj/Release/net10.0 outputs would cause CS0579, with actionable recovery instructions. Telemetry UT flake: AgentFrameworkResponseHandlerTelemetryTests was using a plain List<Activity> for OTel's InMemoryExporter. The exporter writes from background Activity completion callbacks while parallel tests on the same global ActivitySource feed every listener, racing against the assertion's enumeration and throwing 'Collection was modified'. Replaced with a small thread-safe ConcurrentActivityList that locks add/enumerate and returns a snapshot for assertions.
0bf21e4 to
7db1639
Compare
SergeyMenshykh
approved these changes
May 7, 2026
lokitoth
approved these changes
May 7, 2026
This was referenced May 8, 2026
This was referenced May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI run https://github.com/microsoft/agent-framework/actions/runs/25446865848/job/74653338378 failed in the
dotnet-foundry-hosted-itjob with:Root cause
Job run two MSBuild back to back on same tree:
Build Foundry hosted IT (and its deps)filldotnet/src/<lib>/bin/Release/net10.0/*.dll. Helper process (VBCSCompiler) keep file handle open.it-build-image.ps1rundotnet publishforlinux-musl-x64. Publish rebuild same lib DLL into same path. First build still hold handle. Boom: MSB3026.Fix
In
it-build-image.ps1add explicit opt-in switch-UsePrebuiltProjectReferences. CI pass switch -> publish skip ProjectReference rebuild, eat prebuilt DLL in place. No file lock fight, no extra rebuild.Local default = no switch = publish rebuild as normal. If user have stale
obj/Release/net10.0from old build, preflight throw clear error: tell user to pass switch OR delete old obj. No silent stale image.CI keep prebuild step. Test
--no-buildneed it too.Bonus: fix flaky UT
Same PR run hit flaky test
AgentFrameworkResponseHandlerTelemetryTests.CreateAsync_AlreadyInstrumentedAgent_EmitsSingleSpanPerRunAsync:Test use plain
List<Activity>for OTelAddInMemoryExporter. Exporter write from background Activity stop callback. Parallel test on same globalActivitySourcefeed every listener. Add race with assertion enumerate. Boom.Fix: tiny
ConcurrentActivityList : ICollection<Activity>wrapper. Lock add/enumerate. Test callSnapshot()for assertion (lock + copy). All 4 telemetry test use it.Verification
Local repro on Windows, three path:
-UsePrebuiltProjectReferencesAbstractions.dllticks unchanged before/afterTelemetry UT: 30 isolated runs + 5 full assembly runs (216 test each), 0 fail.