Repository navigation
Fix parallel-build race condition on RunnableProjects DLL - #54380
Conversation
BuildTestPackages.targets invoked Pack on TemplateSearch.TemplateDiscovery with different global properties (PackageOutputPath, Version), creating a second MSBuild node that cascades to RunnableProjects via ProjectReference. Two concurrent compilations of the same project then contend for the same obj/ output DLL, causing MSB3026 (promoted to error by TreatWarningsAsErrors). Fix: Remove TemplateSearch.TemplateDiscovery from BuildTestPackages.targets and instead copy the nupkg (already produced via the solution's Pack target) to TestPackagesDir in a post-pack target within the csproj itself. This is the same pattern used for Authoring.Tasks in commit 3864319. Co-authored-by: Copilot <[email protected]>
|
A codeflow into the VMR failed twice with a build timing issue in a templating component: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1424051&view=results I was pinged in the infra chat and had copilot review the binlog to try to come up with a fix. This is that proposed fix. |
There was a problem hiding this comment.
Pull request overview
This PR addresses an MSBuild parallel-build race where BuildTestPackages.targets re-packed Microsoft.TemplateSearch.TemplateDiscovery with different global properties, creating concurrent builds that contend over the same obj/ outputs (e.g., RunnableProjects.dll) and can trigger MSB3026.
Changes:
- Removed
Microsoft.TemplateSearch.TemplateDiscoveryfromBuildTestPackages.targetsto avoid re-packing the project with conflicting global properties. - Added a post-pack target in
Microsoft.TemplateSearch.TemplateDiscovery.csprojto copy its produced.nupkginto$(TestLayoutDir)testpackages/for test consumption.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework/BuildTestPackages.targets | Stops re-packing TemplateDiscovery via the test-packaging target to prevent parallel build output contention. |
| src/TemplateEngine/Tools/Microsoft.TemplateSearch.TemplateDiscovery/Microsoft.TemplateSearch.TemplateDiscovery.csproj | Copies the already-packed .nupkg into the test packages directory after Pack. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
@marcpopMSFT, I hope you don't mind that I applied a comment wording improvement from copilot and enabled atuo-merge. I've seen this intermittent failure three times in the past 24 hours. Let's get this in 😃 |
Supportive of this approach. I think we need to be more aggressive about helping each other get our PRs in that are infra or targeted fixes as those should be the easiest to get through. Spend our energy on the complex changes or risky changes. |
PR dotnet#54380 added CopyPackageToTestPackagesDir targets to both Authoring.Tasks and TemplateDiscovery. A subsequent VMR-only fix (73010df) added the DotNetBuild guard to Authoring.Tasks but that hasn't flowed back to SDK main, and TemplateDiscovery never received the guard at all. Without this guard, the targets run during VMR source-build where PackageId/PackageVersion are not set in the outer cross-targeting evaluation, producing MSB3030 trying to copy '..nupkg'. This adds the guard to both projects and updates the XML comments. Co-authored-by: Copilot <[email protected]>
BuildTestPackages.targets invoked Pack on TemplateSearch.TemplateDiscovery with different global properties (PackageOutputPath, Version), creating a second MSBuild node that cascades to RunnableProjects via ProjectReference. Two concurrent compilations of the same project then contend for the same obj/ output DLL, causing MSB3026 (promoted to error by TreatWarningsAsErrors).
Fix: Remove TemplateSearch.TemplateDiscovery from BuildTestPackages.targets and instead copy the nupkg (already produced via the solution's Pack target) to TestPackagesDir in a post-pack target within the csproj itself.
This is the same pattern used for Authoring.Tasks in commit 3864319.