Repository navigation
Handle project instances that only differ in global properties - #56021
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses dotnet watch crashing when a project graph contains multiple ProjectInstances that share the same (ProjectPath, TargetFramework) but differ in other global properties (regression noted in #54552). The change deduplicates project instances for dotnet-watch’s internal maps and adds a regression test asset + unit test.
Changes:
- Deduplicate inner-build
ProjectGraphNodes by(ProjectPath, TargetFramework)and warn when duplicates differ only in other global properties. - Avoid
ToDictionaryover the full project graph nodes when capturing restored project instances by using a deduped map instead. - Add a new test asset and a unit test that exercises duplicate project instances caused by
ProjectReference AdditionalProperties.
File summaries
| File | Description |
|---|---|
| test/TestAssets/TestProjects/ProjectsWithGlobalProperties/Library/LibraryClass.cs | New test library source that changes behavior based on a global-property-driven constant. |
| test/TestAssets/TestProjects/ProjectsWithGlobalProperties/Library/Library.csproj | New test library project that varies outputs per global property and isolates output paths. |
| test/TestAssets/TestProjects/ProjectsWithGlobalProperties/App/Program.cs | New test app that loads different library outputs to validate the scenario. |
| test/TestAssets/TestProjects/ProjectsWithGlobalProperties/App/App.csproj | New test app referencing the same project twice with different AdditionalProperties. |
| test/dotnet-watch.Tests/Build/ProjectGraphFactoryTests.cs | Adds regression coverage for duplicate project instances with different global properties. |
| src/Dotnet.Watch/Watch/Build/LoadedProjectGraph.cs | Introduces a deduped inner-build node map and warning for global-property-only differences. |
| src/Dotnet.Watch/Watch/Build/EvaluationResult.cs | Switches restored-project snapshot creation to use the deduped instance map. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
🔍 Build Failure AnalysisSummary — A C# syntax error in a newly-added test method breaks compilation of Root cause: invalid escaped quotes inside an interpolated-string expression holeThe new var actual = map.Select(entry => $"{entry.Key.ProjectPath} TFM={entry.Key.TargetFramework} X={(entry.Value.GlobalProperties.TryGetValue(\"X\", out var x) ? x : \"\")}").ToArray();Inside the Affected files / errors
Proposed fix - var actual = map.Select(entry => $"{entry.Key.ProjectPath} TFM={entry.Key.TargetFramework} X={(entry.Value.GlobalProperties.TryGetValue(\"X\", out var x) ? x : \"\")}").ToArray();
+ var actual = map.Select(entry => $"{entry.Key.ProjectPath} TFM={entry.Key.TargetFramework} X={(entry.Value.GlobalProperties.TryGetValue("X", out var x) ? x : "")}").ToArray();Build overviewEvery one of the 10 build legs ( All MSBuild errors
🤖 Generated by the Build Failure Analysis workflow using (a href="(dev.azure.com/redacted) · commit 280811e
|
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · auto · 127.6 AIC · ⌖ 1.91 AIC · ⊞ 7.1K · ◷
Fixes #54552