Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide MSB5009 error with project's name and it's GUID #5835

43 changes: 43 additions & 0 deletions src/Build.UnitTests/Construction/SolutionFile_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,49 @@ public void MissingNestedProject()
Assert.True(false);
}

/// <summary>
/// Checks whether incorrect nesting found within the solution file is reported MSB5009 error
/// with the incorrectly nested project's name and it's GUID
/// </summary>
[Fact]
public void IncorrectlyNestedProjectErrorContainsProjectNameAndGuid()
{
string solutionFileContents =
@"
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project('{2150E333-8FDC-42A3-9474-1A3956D46DE8}') = 'SolutionFolder', 'SolutionFolder', '{5EE89BD0-04E3-4600-9CF2-D083A77A9448}'
EndProject
Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'ConsoleApp1', 'ConsoleApp1\ConsoleApp1.csproj', '{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E}'
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E} = {5EE89BD0-04E3-4600-9CF2-D083A77A9448}
{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E} = {5EE89BD0-04E3-4600-9CF2-D083A77A9449}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AF600A67-B616-453E-9B27-4407D654F66E}
EndGlobalSection
EndGlobal
";

InvalidProjectFileException e = Should.Throw<InvalidProjectFileException>(() => ParseSolutionHelper(solutionFileContents));

e.ErrorCode.ShouldBe("MSB5009");
e.Message.ShouldContain("{1484A47E-F4C5-4700-B13F-A2BDB6ADD35E}");
e.Message.ShouldContain("ConsoleApp1");
}

/// <summary>
/// Verifies that we correctly identify solution folders and mercury non-buildable projects both as
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Construction/Solution/ProjectInSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ internal string GetUniqueProjectName()
if (!ParentSolution.ProjectsByGuid.TryGetValue(ParentProjectGuid, out ProjectInSolution proj))
{
ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(proj != null, "SubCategoryForSolutionParsingErrors",
new BuildEventFileInfo(ParentSolution.FullPath), "SolutionParseNestedProjectError");
new BuildEventFileInfo(ParentSolution.FullPath), "SolutionParseNestedProjectErrorWithNameAndGuid", ProjectName, ProjectGuid, ParentProjectGuid);
}

uniqueName = proj.GetUniqueProjectName() + "\\";
Expand Down Expand Up @@ -409,7 +409,7 @@ internal string GetOriginalProjectName()
if (!ParentSolution.ProjectsByGuid.TryGetValue(ParentProjectGuid, out ProjectInSolution parent))
{
ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(parent != null, "SubCategoryForSolutionParsingErrors",
new BuildEventFileInfo(ParentSolution.FullPath), "SolutionParseNestedProjectError");
new BuildEventFileInfo(ParentSolution.FullPath), "SolutionParseNestedProjectErrorWithNameAndGuid", ProjectName, ProjectGuid, ParentProjectGuid);
}

projectName = parent.GetOriginalProjectName() + "\\";
Expand Down
4 changes: 4 additions & 0 deletions src/Shared/Resources/Strings.shared.resx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
<value>MSB5008: Error parsing the solution configuration section in solution file. The entry "{0}" is invalid.</value>
<comment>{StrBegin="MSB5008: "}UE: The solution filename is provided separately to loggers.</comment>
</data>
<data name="SolutionParseNestedProjectErrorWithNameAndGuid" Visibility="Public">
<value>MSB5009: Error parsing the project "{0}" section with GUID: "{1}". It is nested under "{2}" but that project is not found in the solution.</value>
<comment>{StrBegin="MSB5009: "}UE: The solution filename is provided separately to loggers.</comment>
</data>
<data name="SolutionParseNestedProjectError" Visibility="Public">
<value>MSB5009: Error parsing the nested project section in solution file.</value>
<comment>{StrBegin="MSB5009: "}UE: The solution filename is provided separately to loggers.</comment>
Expand Down
7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Shared/Resources/xlf/Strings.shared.en.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Shared/Resources/xlf/Strings.shared.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading