From f58841afa55950af4a69c58a191e397e53b8c105 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:08:44 +0000 Subject: [PATCH 1/8] Add EventLogger for investigating graph build error reporting Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- nuget.config.override | 6 + src/Build/Logging/EventLogger.cs | 210 +++++++++++++++++++++++++++++++ src/Build/Microsoft.Build.csproj | 1 + 3 files changed, 217 insertions(+) create mode 100644 nuget.config.override create mode 100644 src/Build/Logging/EventLogger.cs diff --git a/nuget.config.override b/nuget.config.override new file mode 100644 index 00000000000..1043872131e --- /dev/null +++ b/nuget.config.override @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Build/Logging/EventLogger.cs b/src/Build/Logging/EventLogger.cs new file mode 100644 index 00000000000..d7eec0e8841 --- /dev/null +++ b/src/Build/Logging/EventLogger.cs @@ -0,0 +1,210 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using Microsoft.Build.Framework; + +namespace Microsoft.Build.Logging +{ + /// + /// A logger that captures all events to a JSON file for analysis. + /// This logger listens to the same events as TerminalLogger. + /// + public class EventLogger : ILogger + { + private string? _outputFile; + private StreamWriter? _writer; + private readonly List _events = new(); + + public string? Parameters { get; set; } + public LoggerVerbosity Verbosity { get; set; } = LoggerVerbosity.Normal; + + public void Initialize(IEventSource eventSource) + { + // Parse output file from parameters + _outputFile = Parameters ?? "events.json"; + _writer = new StreamWriter(_outputFile, false); + + // Subscribe to the same events as TerminalLogger + eventSource.BuildStarted += BuildStarted; + eventSource.BuildFinished += BuildFinished; + eventSource.ProjectStarted += ProjectStarted; + eventSource.ProjectFinished += ProjectFinished; + eventSource.TargetStarted += TargetStarted; + eventSource.TargetFinished += TargetFinished; + eventSource.TaskStarted += TaskStarted; + eventSource.StatusEventRaised += StatusEventRaised; + eventSource.MessageRaised += MessageRaised; + eventSource.WarningRaised += WarningRaised; + eventSource.ErrorRaised += ErrorRaised; + } + + public void Shutdown() + { + if (_writer != null) + { + _writer.Close(); + _writer.Dispose(); + } + } + + private void WriteEvent(string eventType, object eventData) + { + var eventInfo = new + { + EventType = eventType, + Timestamp = DateTime.Now, + Data = eventData + }; + + var json = JsonSerializer.Serialize(eventInfo); + + lock (_events) + { + _writer?.WriteLine(json); + _writer?.Flush(); + _events.Add(eventInfo); + } + } + + private void BuildStarted(object sender, BuildStartedEventArgs e) + { + WriteEvent("BuildStarted", new { e.Message, e.BuildEventContext, e.Timestamp }); + } + + private void BuildFinished(object sender, BuildFinishedEventArgs e) + { + WriteEvent("BuildFinished", new { e.Message, e.Succeeded, e.BuildEventContext, e.Timestamp }); + } + + private void ProjectStarted(object sender, ProjectStartedEventArgs e) + { + WriteEvent("ProjectStarted", new + { + e.Message, + e.ProjectFile, + e.TargetNames, + e.BuildEventContext, + e.ParentProjectBuildEventContext, + e.Timestamp, + GlobalProperties = e.GlobalProperties != null ? new Dictionary(e.GlobalProperties) : null + }); + } + + private void ProjectFinished(object sender, ProjectFinishedEventArgs e) + { + WriteEvent("ProjectFinished", new + { + e.Message, + e.ProjectFile, + e.Succeeded, + e.BuildEventContext, + e.Timestamp + }); + } + + private void TargetStarted(object sender, TargetStartedEventArgs e) + { + WriteEvent("TargetStarted", new + { + e.Message, + e.TargetName, + e.ProjectFile, + e.TargetFile, + e.BuildEventContext, + e.ParentTarget, + e.Timestamp + }); + } + + private void TargetFinished(object sender, TargetFinishedEventArgs e) + { + WriteEvent("TargetFinished", new + { + e.Message, + e.TargetName, + e.ProjectFile, + e.TargetFile, + e.Succeeded, + e.BuildEventContext, + e.Timestamp + }); + } + + private void TaskStarted(object sender, TaskStartedEventArgs e) + { + WriteEvent("TaskStarted", new + { + e.Message, + e.TaskName, + e.ProjectFile, + e.TaskFile, + e.BuildEventContext, + e.Timestamp + }); + } + + private void StatusEventRaised(object sender, BuildStatusEventArgs e) + { + WriteEvent("StatusEventRaised", new + { + e.Message, + e.BuildEventContext, + e.Timestamp, + EventType = e.GetType().Name + }); + } + + private void MessageRaised(object sender, BuildMessageEventArgs e) + { + WriteEvent("MessageRaised", new + { + e.Message, + e.Code, + e.File, + e.LineNumber, + e.ColumnNumber, + e.ProjectFile, + e.Importance, + e.BuildEventContext, + e.Timestamp, + EventType = e.GetType().Name + }); + } + + private void WarningRaised(object sender, BuildWarningEventArgs e) + { + WriteEvent("WarningRaised", new + { + e.Message, + e.Code, + e.File, + e.LineNumber, + e.ColumnNumber, + e.ProjectFile, + e.Subcategory, + e.BuildEventContext, + e.Timestamp + }); + } + + private void ErrorRaised(object sender, BuildErrorEventArgs e) + { + WriteEvent("ErrorRaised", new + { + e.Message, + e.Code, + e.File, + e.LineNumber, + e.ColumnNumber, + e.ProjectFile, + e.Subcategory, + e.BuildEventContext, + e.Timestamp + }); + } + } +} diff --git a/src/Build/Microsoft.Build.csproj b/src/Build/Microsoft.Build.csproj index 1ba4d5053e3..a1fb239a127 100644 --- a/src/Build/Microsoft.Build.csproj +++ b/src/Build/Microsoft.Build.csproj @@ -573,6 +573,7 @@ + From f3c3b9af1a2abaca6b3a3e8fa6a845998fb1dff9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:20:22 +0000 Subject: [PATCH 2/8] Implement fix to show source project in graph build errors Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/Build/Graph/GraphBuilder.cs | 52 +++++++++++++++++++-- src/Build/Resources/Strings.resx | 10 ++++ src/Build/Resources/xlf/Strings.cs.xlf | 11 +++++ src/Build/Resources/xlf/Strings.de.xlf | 11 +++++ src/Build/Resources/xlf/Strings.es.xlf | 11 +++++ src/Build/Resources/xlf/Strings.fr.xlf | 11 +++++ src/Build/Resources/xlf/Strings.it.xlf | 11 +++++ src/Build/Resources/xlf/Strings.ja.xlf | 11 +++++ src/Build/Resources/xlf/Strings.ko.xlf | 11 +++++ src/Build/Resources/xlf/Strings.pl.xlf | 11 +++++ src/Build/Resources/xlf/Strings.pt-BR.xlf | 11 +++++ src/Build/Resources/xlf/Strings.ru.xlf | 11 +++++ src/Build/Resources/xlf/Strings.tr.xlf | 11 +++++ src/Build/Resources/xlf/Strings.zh-Hans.xlf | 11 +++++ src/Build/Resources/xlf/Strings.zh-Hant.xlf | 11 +++++ 15 files changed, 201 insertions(+), 4 deletions(-) diff --git a/src/Build/Graph/GraphBuilder.cs b/src/Build/Graph/GraphBuilder.cs index 35ecbb5122a..bf983b04142 100644 --- a/src/Build/Graph/GraphBuilder.cs +++ b/src/Build/Graph/GraphBuilder.cs @@ -53,6 +53,14 @@ internal class GraphBuilder private IReadOnlyDictionary> _solutionDependencies; private ConcurrentDictionary> _platformNegotiationInstancesCache = new(); + /// + /// Tracks which projects are referencing each project. Used to provide better error messages + /// when a referenced project fails to load. + /// Key: The project being referenced + /// Value: Set of projects that reference it + /// + private readonly ConcurrentDictionary> _projectReferrers = new(); + public GraphBuilder( IEnumerable entryPoints, ProjectCollection projectCollection, @@ -528,10 +536,42 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) // TODO: ProjectInstance just converts the dictionary back to a PropertyDictionary, so find a way to directly provide it. var globalProperties = configurationMetadata.GlobalProperties.ToDictionary(); - var projectInstance = _projectInstanceFactory( - configurationMetadata.ProjectFullPath, - globalProperties, - _projectCollection); + ProjectInstance projectInstance; + try + { + projectInstance = _projectInstanceFactory( + configurationMetadata.ProjectFullPath, + globalProperties, + _projectCollection); + } + catch (InvalidProjectFileException ex) + { + // Enrich the exception with information about which project(s) referenced this project + if (_projectReferrers.TryGetValue(configurationMetadata, out var referrers) && !referrers.IsEmpty) + { + // Create a new exception with enriched message that includes the referring project(s) + string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); + string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( + "ProjectGraphProjectFileCannotBeLoadedWithReferrers", + configurationMetadata.ProjectFullPath, + referrerList, + ex.BaseMessage); + + throw new InvalidProjectFileException( + ex.ProjectFile ?? configurationMetadata.ProjectFullPath, + ex.LineNumber, + ex.ColumnNumber, + ex.EndLineNumber, + ex.EndColumnNumber, + enrichedMessage, + ex.ErrorSubcategory, + ex.ErrorCode, + ex.HelpKeyword, + ex.InnerException); + } + + throw; + } if (projectInstance == null) { @@ -585,6 +625,10 @@ private void SubmitProjectForParsing(ConfigurationMetadata projectToEvaluate) referenceInfo.ReferenceConfiguration.ProjectFullPath)); } + // Track that this project is referencing the target project + _projectReferrers.GetOrAdd(referenceInfo.ReferenceConfiguration, _ => new ConcurrentBag()) + .Add(parsedProject.ProjectInstance.FullPath); + SubmitProjectForParsing(referenceInfo.ReferenceConfiguration); referenceInfos.Add(referenceInfo); diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index b9bb5011c83..12c65fc768d 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1830,6 +1830,16 @@ Utilization: {0} Average Utilization: {1:###.0} request a target to build itself (perhaps via a chain of other targets) + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message + + MSB4252: Project "{0}" with global properties ({1}) diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index 2a17c8ea8cf..4fedb66e9d2 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index a0afccd7157..37f94cc8cec 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index 4ffb1eaeee4..f71ebd66965 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index 32010d4dfc0..bd833559c1e 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index 4a0a49af8a2..925ddfdcdd9 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index cc1a03df410..f89c5a49d77 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index 907dd46d818..e6951b53cfa 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index f21ad0b9af1..208836b563f 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index 5f2af03c19a..215922760da 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index a4420a5f842..dbc4f66b0ca 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index d4b684016ae..d3364ebf8b3 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index da371088b6a..f89ddf27f99 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index a124d491633..ce7e50f765f 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -823,6 +823,17 @@ {StrBegin="MSB4250: "} LOCALIZATION: Do not localize the following words: ProjectGraph, ProjectReference, ToolsVersion. + + + + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference it + {2} is the original error message From d3b6d9d5f7c1f7ff185bc0d3ce3f39f4045fe2cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:28:52 +0000 Subject: [PATCH 3/8] Add unit tests and clean up investigation code Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- nuget.config.override | 6 - .../Graph/ProjectGraph_Tests.cs | 69 ++++++ src/Build/Logging/EventLogger.cs | 210 ------------------ src/Build/Microsoft.Build.csproj | 1 - 4 files changed, 69 insertions(+), 217 deletions(-) delete mode 100644 nuget.config.override delete mode 100644 src/Build/Logging/EventLogger.cs diff --git a/nuget.config.override b/nuget.config.override deleted file mode 100644 index 1043872131e..00000000000 --- a/nuget.config.override +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs index 5bf891c4707..4fd17bae34b 100644 --- a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs +++ b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs @@ -2923,6 +2923,75 @@ public void GetTargetListsWithSolutionInvalidTargets(string entryTarget) } } + [Fact] + public void InvalidProjectReferenceErrorIncludesReferringProject() + { + using (var env = TestEnvironment.Create()) + { + // Create a project that references a non-existent project + TransientTestFile project1 = env.CreateFile("project1.proj", @" + + + + +"); + + // Attempt to create a graph should throw an exception + var exception = Should.Throw(() => new ProjectGraph(project1.Path)); + + // The exception should be an InvalidProjectFileException + exception.InnerExceptions.ShouldHaveSingleItem(); + var innerException = exception.InnerExceptions[0].ShouldBeOfType(); + + // The error message should mention the referring project + innerException.Message.ShouldContain("project1.proj"); + innerException.Message.ShouldContain("referenced by"); + } + } + + [Fact] + public void InvalidProjectReferenceErrorIncludesMultipleReferringProjects() + { + using (var env = TestEnvironment.Create()) + { + // Create two projects that both reference a non-existent project + TransientTestFile project1 = env.CreateFile("project1.proj", @" + + + + +"); + + TransientTestFile project2 = env.CreateFile("project2.proj", @" + + + + +"); + + TransientTestFile main = env.CreateFile("main.proj", @" + + + + + +"); + + // Attempt to create a graph should throw an exception + var exception = Should.Throw(() => new ProjectGraph(main.Path)); + + // The exception should be an InvalidProjectFileException + exception.InnerExceptions.ShouldHaveSingleItem(); + var innerException = exception.InnerExceptions[0].ShouldBeOfType(); + + // The error message should mention at least one referring project + innerException.Message.ShouldContain("referenced by"); + bool hasProject1 = innerException.Message.Contains("project1.proj"); + bool hasProject2 = innerException.Message.Contains("project2.proj"); + (hasProject1 || hasProject2).ShouldBeTrue(); + } + } + public void Dispose() { _env.Dispose(); diff --git a/src/Build/Logging/EventLogger.cs b/src/Build/Logging/EventLogger.cs deleted file mode 100644 index d7eec0e8841..00000000000 --- a/src/Build/Logging/EventLogger.cs +++ /dev/null @@ -1,210 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.Json; -using Microsoft.Build.Framework; - -namespace Microsoft.Build.Logging -{ - /// - /// A logger that captures all events to a JSON file for analysis. - /// This logger listens to the same events as TerminalLogger. - /// - public class EventLogger : ILogger - { - private string? _outputFile; - private StreamWriter? _writer; - private readonly List _events = new(); - - public string? Parameters { get; set; } - public LoggerVerbosity Verbosity { get; set; } = LoggerVerbosity.Normal; - - public void Initialize(IEventSource eventSource) - { - // Parse output file from parameters - _outputFile = Parameters ?? "events.json"; - _writer = new StreamWriter(_outputFile, false); - - // Subscribe to the same events as TerminalLogger - eventSource.BuildStarted += BuildStarted; - eventSource.BuildFinished += BuildFinished; - eventSource.ProjectStarted += ProjectStarted; - eventSource.ProjectFinished += ProjectFinished; - eventSource.TargetStarted += TargetStarted; - eventSource.TargetFinished += TargetFinished; - eventSource.TaskStarted += TaskStarted; - eventSource.StatusEventRaised += StatusEventRaised; - eventSource.MessageRaised += MessageRaised; - eventSource.WarningRaised += WarningRaised; - eventSource.ErrorRaised += ErrorRaised; - } - - public void Shutdown() - { - if (_writer != null) - { - _writer.Close(); - _writer.Dispose(); - } - } - - private void WriteEvent(string eventType, object eventData) - { - var eventInfo = new - { - EventType = eventType, - Timestamp = DateTime.Now, - Data = eventData - }; - - var json = JsonSerializer.Serialize(eventInfo); - - lock (_events) - { - _writer?.WriteLine(json); - _writer?.Flush(); - _events.Add(eventInfo); - } - } - - private void BuildStarted(object sender, BuildStartedEventArgs e) - { - WriteEvent("BuildStarted", new { e.Message, e.BuildEventContext, e.Timestamp }); - } - - private void BuildFinished(object sender, BuildFinishedEventArgs e) - { - WriteEvent("BuildFinished", new { e.Message, e.Succeeded, e.BuildEventContext, e.Timestamp }); - } - - private void ProjectStarted(object sender, ProjectStartedEventArgs e) - { - WriteEvent("ProjectStarted", new - { - e.Message, - e.ProjectFile, - e.TargetNames, - e.BuildEventContext, - e.ParentProjectBuildEventContext, - e.Timestamp, - GlobalProperties = e.GlobalProperties != null ? new Dictionary(e.GlobalProperties) : null - }); - } - - private void ProjectFinished(object sender, ProjectFinishedEventArgs e) - { - WriteEvent("ProjectFinished", new - { - e.Message, - e.ProjectFile, - e.Succeeded, - e.BuildEventContext, - e.Timestamp - }); - } - - private void TargetStarted(object sender, TargetStartedEventArgs e) - { - WriteEvent("TargetStarted", new - { - e.Message, - e.TargetName, - e.ProjectFile, - e.TargetFile, - e.BuildEventContext, - e.ParentTarget, - e.Timestamp - }); - } - - private void TargetFinished(object sender, TargetFinishedEventArgs e) - { - WriteEvent("TargetFinished", new - { - e.Message, - e.TargetName, - e.ProjectFile, - e.TargetFile, - e.Succeeded, - e.BuildEventContext, - e.Timestamp - }); - } - - private void TaskStarted(object sender, TaskStartedEventArgs e) - { - WriteEvent("TaskStarted", new - { - e.Message, - e.TaskName, - e.ProjectFile, - e.TaskFile, - e.BuildEventContext, - e.Timestamp - }); - } - - private void StatusEventRaised(object sender, BuildStatusEventArgs e) - { - WriteEvent("StatusEventRaised", new - { - e.Message, - e.BuildEventContext, - e.Timestamp, - EventType = e.GetType().Name - }); - } - - private void MessageRaised(object sender, BuildMessageEventArgs e) - { - WriteEvent("MessageRaised", new - { - e.Message, - e.Code, - e.File, - e.LineNumber, - e.ColumnNumber, - e.ProjectFile, - e.Importance, - e.BuildEventContext, - e.Timestamp, - EventType = e.GetType().Name - }); - } - - private void WarningRaised(object sender, BuildWarningEventArgs e) - { - WriteEvent("WarningRaised", new - { - e.Message, - e.Code, - e.File, - e.LineNumber, - e.ColumnNumber, - e.ProjectFile, - e.Subcategory, - e.BuildEventContext, - e.Timestamp - }); - } - - private void ErrorRaised(object sender, BuildErrorEventArgs e) - { - WriteEvent("ErrorRaised", new - { - e.Message, - e.Code, - e.File, - e.LineNumber, - e.ColumnNumber, - e.ProjectFile, - e.Subcategory, - e.BuildEventContext, - e.Timestamp - }); - } - } -} diff --git a/src/Build/Microsoft.Build.csproj b/src/Build/Microsoft.Build.csproj index a1fb239a127..1ba4d5053e3 100644 --- a/src/Build/Microsoft.Build.csproj +++ b/src/Build/Microsoft.Build.csproj @@ -573,7 +573,6 @@ - From 1042387fbd57e50d4e55e5c2188220755e3ee0e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:33:39 +0000 Subject: [PATCH 4/8] Remove duplicate text from error message Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/Build/Graph/GraphBuilder.cs | 5 ++--- src/Build/Resources/Strings.resx | 9 ++++----- src/Build/Resources/xlf/Strings.cs.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.de.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.es.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.fr.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.it.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.ja.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.ko.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.pl.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.pt-BR.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.ru.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.tr.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.zh-Hans.xlf | 11 +++++------ src/Build/Resources/xlf/Strings.zh-Hant.xlf | 11 +++++------ 15 files changed, 71 insertions(+), 86 deletions(-) diff --git a/src/Build/Graph/GraphBuilder.cs b/src/Build/Graph/GraphBuilder.cs index bf983b04142..2eb3b5d34ec 100644 --- a/src/Build/Graph/GraphBuilder.cs +++ b/src/Build/Graph/GraphBuilder.cs @@ -551,9 +551,8 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) { // Create a new exception with enriched message that includes the referring project(s) string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); - string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( + string referrerInfo = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( "ProjectGraphProjectFileCannotBeLoadedWithReferrers", - configurationMetadata.ProjectFullPath, referrerList, ex.BaseMessage); @@ -563,7 +562,7 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, - enrichedMessage, + referrerInfo, ex.ErrorSubcategory, ex.ErrorCode, ex.HelpKeyword, diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index 12c65fc768d..52ba48a9728 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1831,13 +1831,12 @@ Utilization: {0} Average Utilization: {1:###.0} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index 4fedb66e9d2..f21c9deb539 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index 37f94cc8cec..2f4bd01ccd7 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index f71ebd66965..de5e8e7fe90 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index bd833559c1e..db4b5c4fa1a 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index 925ddfdcdd9..1393469bc66 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index f89c5a49d77..a9409e46d03 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index e6951b53cfa..ecd0a8d2db8 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index 208836b563f..9b6880019ba 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index 215922760da..bcc0100fb91 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index dbc4f66b0ca..c54a56ac0c5 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index d3364ebf8b3..8eaa6719091 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index f89ddf27f99..b1525d393fa 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index ce7e50f765f..daffa2107e6 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -826,14 +826,13 @@ - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} - The project file '{0}' could not be loaded. It is referenced by: {1}. {2} + It is referenced by: {0}. {1} + It is referenced by: {0}. {1} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference it - {2} is the original error message + along with information about which project(s) are referencing the failed project. This is prepended to the original error message. + {0} is a comma-separated list of projects that reference the failed project + {1} is the original error message From f824875bfbcc8c4406f1053ce6018e50b0e48cdd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:48:25 +0000 Subject: [PATCH 5/8] Improve error message grammar and remove duplication Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/Build/Graph/GraphBuilder.cs | 16 +++++++++++++--- src/Build/Resources/Strings.resx | 9 +++++---- src/Build/Resources/xlf/Strings.cs.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.de.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.es.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.fr.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.it.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.ja.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.ko.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.pl.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.pt-BR.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.ru.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.tr.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.zh-Hans.xlf | 11 ++++++----- src/Build/Resources/xlf/Strings.zh-Hant.xlf | 11 ++++++----- 15 files changed, 96 insertions(+), 72 deletions(-) diff --git a/src/Build/Graph/GraphBuilder.cs b/src/Build/Graph/GraphBuilder.cs index 2eb3b5d34ec..e4152b37f14 100644 --- a/src/Build/Graph/GraphBuilder.cs +++ b/src/Build/Graph/GraphBuilder.cs @@ -551,10 +551,20 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) { // Create a new exception with enriched message that includes the referring project(s) string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); - string referrerInfo = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( + + // Extract specific error details by removing the generic prefix if present + string errorDetails = ex.BaseMessage; + const string genericPrefix = "The project file could not be loaded. "; + if (errorDetails.StartsWith(genericPrefix, StringComparison.Ordinal)) + { + errorDetails = errorDetails.Substring(genericPrefix.Length); + } + + string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( "ProjectGraphProjectFileCannotBeLoadedWithReferrers", + configurationMetadata.ProjectFullPath, referrerList, - ex.BaseMessage); + errorDetails); throw new InvalidProjectFileException( ex.ProjectFile ?? configurationMetadata.ProjectFullPath, @@ -562,7 +572,7 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, - referrerInfo, + enrichedMessage, ex.ErrorSubcategory, ex.ErrorCode, ex.HelpKeyword, diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index 52ba48a9728..cd304edd32f 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1831,12 +1831,13 @@ Utilization: {0} Average Utilization: {1:###.0} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index f21c9deb539..444bc920ed1 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index 2f4bd01ccd7..b1654f102af 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index de5e8e7fe90..e7ec2a80bc6 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index db4b5c4fa1a..bb8ef225e99 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index 1393469bc66..f2bcf7936d5 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index a9409e46d03..546cc9e7d7d 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index ecd0a8d2db8..60de56a32ee 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index 9b6880019ba..df7f24ad984 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index bcc0100fb91..faf9f3cf7fa 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index c54a56ac0c5..db64398d88d 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index 8eaa6719091..573f32a70aa 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index b1525d393fa..9620a31d275 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index daffa2107e6..1337d8fd37a 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -826,13 +826,14 @@ - It is referenced by: {0}. {1} - It is referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. {2} + The project file '{0}' could not be loaded when referenced by {1}. {2} This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. This is prepended to the original error message. - {0} is a comma-separated list of projects that reference the failed project - {1} is the original error message + along with information about which project(s) are referencing the failed project. + {0} is the path to the project that failed to load + {1} is a comma-separated list of projects that reference the failed project + {2} is the specific error details From 7531ed4227f87fe394bd171bea30311b3f00ca7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:13:27 +0000 Subject: [PATCH 6/8] Remove fragile string manipulation from error enrichment Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/Build/Graph/GraphBuilder.cs | 51 ++++++++------------- src/Build/Resources/Strings.resx | 10 ++-- src/Build/Resources/xlf/Strings.cs.xlf | 14 +++--- src/Build/Resources/xlf/Strings.de.xlf | 14 +++--- src/Build/Resources/xlf/Strings.es.xlf | 14 +++--- src/Build/Resources/xlf/Strings.fr.xlf | 14 +++--- src/Build/Resources/xlf/Strings.it.xlf | 14 +++--- src/Build/Resources/xlf/Strings.ja.xlf | 14 +++--- src/Build/Resources/xlf/Strings.ko.xlf | 14 +++--- src/Build/Resources/xlf/Strings.pl.xlf | 14 +++--- src/Build/Resources/xlf/Strings.pt-BR.xlf | 14 +++--- src/Build/Resources/xlf/Strings.ru.xlf | 14 +++--- src/Build/Resources/xlf/Strings.tr.xlf | 14 +++--- src/Build/Resources/xlf/Strings.zh-Hans.xlf | 14 +++--- src/Build/Resources/xlf/Strings.zh-Hant.xlf | 14 +++--- 15 files changed, 100 insertions(+), 143 deletions(-) diff --git a/src/Build/Graph/GraphBuilder.cs b/src/Build/Graph/GraphBuilder.cs index e4152b37f14..8c08172eca6 100644 --- a/src/Build/Graph/GraphBuilder.cs +++ b/src/Build/Graph/GraphBuilder.cs @@ -544,42 +544,27 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) globalProperties, _projectCollection); } - catch (InvalidProjectFileException ex) + catch (InvalidProjectFileException ex) when (_projectReferrers.TryGetValue(configurationMetadata, out var referrers) && !referrers.IsEmpty) { // Enrich the exception with information about which project(s) referenced this project - if (_projectReferrers.TryGetValue(configurationMetadata, out var referrers) && !referrers.IsEmpty) - { - // Create a new exception with enriched message that includes the referring project(s) - string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); - - // Extract specific error details by removing the generic prefix if present - string errorDetails = ex.BaseMessage; - const string genericPrefix = "The project file could not be loaded. "; - if (errorDetails.StartsWith(genericPrefix, StringComparison.Ordinal)) - { - errorDetails = errorDetails.Substring(genericPrefix.Length); - } - - string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( - "ProjectGraphProjectFileCannotBeLoadedWithReferrers", - configurationMetadata.ProjectFullPath, - referrerList, - errorDetails); - - throw new InvalidProjectFileException( - ex.ProjectFile ?? configurationMetadata.ProjectFullPath, - ex.LineNumber, - ex.ColumnNumber, - ex.EndLineNumber, - ex.EndColumnNumber, - enrichedMessage, - ex.ErrorSubcategory, - ex.ErrorCode, - ex.HelpKeyword, - ex.InnerException); - } + string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); + + string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( + "ProjectGraphProjectFileCannotBeLoadedWithReferrers", + referrerList, + ex.Message); - throw; + throw new InvalidProjectFileException( + ex.ProjectFile ?? configurationMetadata.ProjectFullPath, + ex.LineNumber, + ex.ColumnNumber, + ex.EndLineNumber, + ex.EndColumnNumber, + enrichedMessage, + ex.ErrorSubcategory, + ex.ErrorCode, + ex.HelpKeyword, + ex.InnerException); } if (projectInstance == null) diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index cd304edd32f..ef77a35dab0 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1831,13 +1831,11 @@ Utilization: {0} Average Utilization: {1:###.0} - The project file '{0}' could not be loaded when referenced by {1}. {2} + Referenced by: {0}. {1} - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index 444bc920ed1..2e96fdb1244 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index b1654f102af..6162b9ef521 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index e7ec2a80bc6..4ce2b86519d 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index bb8ef225e99..a9415d139ab 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index f2bcf7936d5..257a237aae3 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index 546cc9e7d7d..f0ce9c4177b 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index 60de56a32ee..765fbe837b2 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index df7f24ad984..3cdcbeffec1 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index faf9f3cf7fa..c5ffd86b901 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index db64398d88d..ad435c4b802 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index 573f32a70aa..34ac89ebfeb 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index 9620a31d275..5a040da0a17 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index 1337d8fd37a..4a52066fd38 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -826,14 +826,12 @@ - The project file '{0}' could not be loaded when referenced by {1}. {2} - The project file '{0}' could not be loaded when referenced by {1}. {2} - - This message is shown during static graph construction when a referenced project file cannot be loaded, - along with information about which project(s) are referencing the failed project. - {0} is the path to the project that failed to load - {1} is a comma-separated list of projects that reference the failed project - {2} is the specific error details + Referenced by: {0}. {1} + Referenced by: {0}. {1} + + This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. + {0} is a comma-separated list of projects that reference the failed project + {1} is the complete original error message From 57fab1e7794927a1004ffbfaf361d9a8f610f678 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:00:06 +0000 Subject: [PATCH 7/8] Make ProjectGraph referrer tests invariant-culture Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/e81f3c77-947e-4edf-b1bb-c77c5c516dfb Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- src/Build.UnitTests/Graph/ProjectGraph_Tests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs index 4fd17bae34b..29124b3d0a5 100644 --- a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs +++ b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs @@ -2924,6 +2924,7 @@ public void GetTargetListsWithSolutionInvalidTargets(string entryTarget) } [Fact] + [UseInvariantCulture] public void InvalidProjectReferenceErrorIncludesReferringProject() { using (var env = TestEnvironment.Create()) @@ -2945,11 +2946,12 @@ public void InvalidProjectReferenceErrorIncludesReferringProject() // The error message should mention the referring project innerException.Message.ShouldContain("project1.proj"); - innerException.Message.ShouldContain("referenced by"); + innerException.Message.ShouldContain("Referenced by:"); } } [Fact] + [UseInvariantCulture] public void InvalidProjectReferenceErrorIncludesMultipleReferringProjects() { using (var env = TestEnvironment.Create()) @@ -2985,7 +2987,7 @@ public void InvalidProjectReferenceErrorIncludesMultipleReferringProjects() var innerException = exception.InnerExceptions[0].ShouldBeOfType(); // The error message should mention at least one referring project - innerException.Message.ShouldContain("referenced by"); + innerException.Message.ShouldContain("Referenced by:"); bool hasProject1 = innerException.Message.Contains("project1.proj"); bool hasProject2 = innerException.Message.Contains("project2.proj"); (hasProject1 || hasProject2).ShouldBeTrue(); From af0c34738bfe524fab97a1ccd6a6dbc685863ee6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 17:50:09 +0000 Subject: [PATCH 8/8] Fix double-project-file message and strengthen diagnostic tests Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/b7ac2159-283b-4139-bb0b-1aa7376178b8 Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com> --- .../Graph/ProjectGraph_Tests.cs | 119 ++++++++++-------- src/Build/Graph/GraphBuilder.cs | 14 ++- src/Build/Resources/Strings.resx | 10 +- src/Build/Resources/xlf/Strings.cs.xlf | 14 ++- src/Build/Resources/xlf/Strings.de.xlf | 14 ++- src/Build/Resources/xlf/Strings.es.xlf | 14 ++- src/Build/Resources/xlf/Strings.fr.xlf | 14 ++- src/Build/Resources/xlf/Strings.it.xlf | 14 ++- src/Build/Resources/xlf/Strings.ja.xlf | 14 ++- src/Build/Resources/xlf/Strings.ko.xlf | 14 ++- src/Build/Resources/xlf/Strings.pl.xlf | 14 ++- src/Build/Resources/xlf/Strings.pt-BR.xlf | 14 ++- src/Build/Resources/xlf/Strings.ru.xlf | 14 ++- src/Build/Resources/xlf/Strings.tr.xlf | 14 ++- src/Build/Resources/xlf/Strings.zh-Hans.xlf | 14 ++- src/Build/Resources/xlf/Strings.zh-Hant.xlf | 14 ++- 16 files changed, 185 insertions(+), 140 deletions(-) diff --git a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs index 29124b3d0a5..c31f4db7b21 100644 --- a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs +++ b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs @@ -2927,71 +2927,80 @@ public void GetTargetListsWithSolutionInvalidTargets(string entryTarget) [UseInvariantCulture] public void InvalidProjectReferenceErrorIncludesReferringProject() { - using (var env = TestEnvironment.Create()) - { - // Create a project that references a non-existent project - TransientTestFile project1 = env.CreateFile("project1.proj", @" - - - - -"); + using var env = TestEnvironment.Create(); + + TransientTestFile project1 = env.CreateFile("project1.proj", """ + + + + + + """); - // Attempt to create a graph should throw an exception - var exception = Should.Throw(() => new ProjectGraph(project1.Path)); - - // The exception should be an InvalidProjectFileException - exception.InnerExceptions.ShouldHaveSingleItem(); - var innerException = exception.InnerExceptions[0].ShouldBeOfType(); - - // The error message should mention the referring project - innerException.Message.ShouldContain("project1.proj"); - innerException.Message.ShouldContain("Referenced by:"); - } + var exception = Should.Throw(() => new ProjectGraph(project1.Path)); + + exception.InnerExceptions.ShouldHaveSingleItem(); + var innerException = exception.InnerExceptions[0].ShouldBeOfType(); + + // ProjectFile on the exception should be the missing project + innerException.ProjectFile.ShouldContain("missing.proj"); + + // The message should name both the missing file and its referrer in the expected format + innerException.Message.ShouldContain("missing.proj"); + innerException.Message.ShouldContain(project1.Path); + innerException.Message.ShouldContain("could not be loaded"); + innerException.Message.ShouldContain("referenced by"); } [Fact] [UseInvariantCulture] public void InvalidProjectReferenceErrorIncludesMultipleReferringProjects() { - using (var env = TestEnvironment.Create()) - { - // Create two projects that both reference a non-existent project - TransientTestFile project1 = env.CreateFile("project1.proj", @" - - - - -"); + using var env = TestEnvironment.Create(); - TransientTestFile project2 = env.CreateFile("project2.proj", @" - - - - -"); + // Two independent projects both referencing the same missing project + TransientTestFile project1 = env.CreateFile("project1.proj", """ + + + + + + """); - TransientTestFile main = env.CreateFile("main.proj", @" - - - - - -"); + TransientTestFile project2 = env.CreateFile("project2.proj", """ + + + + + + """); - // Attempt to create a graph should throw an exception - var exception = Should.Throw(() => new ProjectGraph(main.Path)); - - // The exception should be an InvalidProjectFileException - exception.InnerExceptions.ShouldHaveSingleItem(); - var innerException = exception.InnerExceptions[0].ShouldBeOfType(); - - // The error message should mention at least one referring project - innerException.Message.ShouldContain("Referenced by:"); - bool hasProject1 = innerException.Message.Contains("project1.proj"); - bool hasProject2 = innerException.Message.Contains("project2.proj"); - (hasProject1 || hasProject2).ShouldBeTrue(); - } + TransientTestFile main = env.CreateFile("main.proj", """ + + + + + + + """); + + var exception = Should.Throw(() => new ProjectGraph(main.Path)); + + exception.InnerExceptions.ShouldHaveSingleItem(); + var innerException = exception.InnerExceptions[0].ShouldBeOfType(); + + // ProjectFile on the exception should be the missing project + innerException.ProjectFile.ShouldContain("missing.proj"); + + // The message should name the missing file and at least one of its referrers + innerException.Message.ShouldContain("missing.proj"); + innerException.Message.ShouldContain("could not be loaded"); + innerException.Message.ShouldContain("referenced by"); + + // At least one of the two referring projects must be named in the message + bool mentionsProject1 = innerException.Message.Contains(project1.Path); + bool mentionsProject2 = innerException.Message.Contains(project2.Path); + (mentionsProject1 || mentionsProject2).ShouldBeTrue(); } public void Dispose() diff --git a/src/Build/Graph/GraphBuilder.cs b/src/Build/Graph/GraphBuilder.cs index 8c08172eca6..fbdfb77a499 100644 --- a/src/Build/Graph/GraphBuilder.cs +++ b/src/Build/Graph/GraphBuilder.cs @@ -548,11 +548,19 @@ private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata) { // Enrich the exception with information about which project(s) referenced this project string referrerList = string.Join(", ", referrers.Distinct().OrderBy(r => r)); - + string enrichedMessage = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( "ProjectGraphProjectFileCannotBeLoadedWithReferrers", - referrerList, - ex.Message); + configurationMetadata.ProjectFullPath, + referrerList); + + // Append the specific reason from the inner exception (e.g. "Could not find file '...'") + // without doing any locale-specific string manipulation on the outer exception's message. + string innerDetail = ex.InnerException?.Message; + if (!string.IsNullOrEmpty(innerDetail)) + { + enrichedMessage = $"{enrichedMessage} {innerDetail}"; + } throw new InvalidProjectFileException( ex.ProjectFile ?? configurationMetadata.ProjectFullPath, diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index ef77a35dab0..6bb6bf3b92c 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1831,11 +1831,13 @@ Utilization: {0} Average Utilization: {1:###.0} - Referenced by: {0}. {1} + The project file '{0}' could not be loaded when referenced by {1}. - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index 2e96fdb1244..827b53d0f22 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index 6162b9ef521..f2e429e9c95 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index 4ce2b86519d..f3026cc2cfb 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index a9415d139ab..537d1b8e96b 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index 257a237aae3..dd5321e69f8 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index f0ce9c4177b..f79b6d3afd8 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index 765fbe837b2..976226ca031 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index 3cdcbeffec1..3c9a6b6b632 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index c5ffd86b901..8f0632b965a 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index ad435c4b802..ac192d1aaa4 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index 34ac89ebfeb..bafff6cd311 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index 5a040da0a17..4b7c576cc3a 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code. diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index 4a52066fd38..76a88ca4a1d 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -826,12 +826,14 @@ - Referenced by: {0}. {1} - Referenced by: {0}. {1} - - This message is prepended to the original error when a referenced project file cannot be loaded during static graph construction. - {0} is a comma-separated list of projects that reference the failed project - {1} is the complete original error message + The project file '{0}' could not be loaded when referenced by {1}. + The project file '{0}' could not be loaded when referenced by {1}. + + This message is shown during static graph construction when a referenced project file cannot be loaded, + along with information about which project(s) are referencing the failed project. + {0} is the full path to the project that failed to load + {1} is a comma-separated list of full paths to the projects that reference the failed project + The specific reason for the load failure (e.g., "Could not find file '...'") is appended separately in code.