diff --git a/src/Microsoft.VisualStudio.SolutionPersistence/Errors.Designer.cs b/src/Microsoft.VisualStudio.SolutionPersistence/Errors.Designer.cs
index 1f985ed7..95ecaeaf 100644
--- a/src/Microsoft.VisualStudio.SolutionPersistence/Errors.Designer.cs
+++ b/src/Microsoft.VisualStudio.SolutionPersistence/Errors.Designer.cs
@@ -115,11 +115,11 @@ internal static string DuplicateName_Args2 {
}
///
- /// Looks up a localized string similar to Project name '{0}' already exists in the solution folder..
+ /// Looks up a localized string similar to Project name '{0}' already exists in the '{1}' solution folder..
///
- internal static string DuplicateProjectName_Arg1 {
+ internal static string DuplicateProjectName_Arg2 {
get {
- return ResourceManager.GetString("DuplicateProjectName_Arg1", resourceCulture);
+ return ResourceManager.GetString("DuplicateProjectName_Arg2", resourceCulture);
}
}
diff --git a/src/Microsoft.VisualStudio.SolutionPersistence/Errors.resx b/src/Microsoft.VisualStudio.SolutionPersistence/Errors.resx
index a3755c1b..fb39ab19 100644
--- a/src/Microsoft.VisualStudio.SolutionPersistence/Errors.resx
+++ b/src/Microsoft.VisualStudio.SolutionPersistence/Errors.resx
@@ -209,8 +209,8 @@
Project path '{0}' already exists in the solution.
Error message. {0} is the file path that already exists.
-
- Project name '{0}' already exists in the solution folder.
+
+ Project name '{0}' already exists in the '{1}' solution folder.
Error message. {0} is the name of the folder.
diff --git a/src/Microsoft.VisualStudio.SolutionPersistence/Model/SolutionModel.cs b/src/Microsoft.VisualStudio.SolutionPersistence/Model/SolutionModel.cs
index 39d69f68..9ac34f21 100644
--- a/src/Microsoft.VisualStudio.SolutionPersistence/Model/SolutionModel.cs
+++ b/src/Microsoft.VisualStudio.SolutionPersistence/Model/SolutionModel.cs
@@ -588,6 +588,8 @@ internal void ValidateProjectName(SolutionProjectModel project)
}
string displayName = project.ActualDisplayName;
+ string folderPath = project.Parent?.Path ?? "Root";
+
foreach (SolutionProjectModel existingProject in this.SolutionProjects)
{
if (!ReferenceEquals(existingProject.Parent, project.Parent) || ReferenceEquals(existingProject, project))
@@ -597,7 +599,7 @@ internal void ValidateProjectName(SolutionProjectModel project)
if (existingProject.ActualDisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase))
{
- throw new SolutionArgumentException(string.Format(Errors.DuplicateProjectName_Arg1, displayName), SolutionErrorType.DuplicateProjectName);
+ throw new SolutionArgumentException(string.Format(Errors.DuplicateProjectName_Arg2, displayName, folderPath), SolutionErrorType.DuplicateProjectName);
}
}
}
diff --git a/test/Microsoft.VisualStudio.SolutionPersistence.Tests/Serialization/Folders.cs b/test/Microsoft.VisualStudio.SolutionPersistence.Tests/Serialization/Folders.cs
index 894a8aa1..a9d72984 100644
--- a/test/Microsoft.VisualStudio.SolutionPersistence.Tests/Serialization/Folders.cs
+++ b/test/Microsoft.VisualStudio.SolutionPersistence.Tests/Serialization/Folders.cs
@@ -143,7 +143,7 @@ public void MoveProjectToFolder()
// Try moving project to folder with existing project
ArgumentException ex = Assert.Throws(() => wanderingProject.MoveToFolder(folderA));
- Assert.Equal(string.Format(Errors.DuplicateProjectName_Arg1, wanderingProject.ActualDisplayName), ex.Message);
+ Assert.Equal(string.Format(Errors.DuplicateProjectName_Arg2, wanderingProject.ActualDisplayName, folderA.Path), ex.Message);
Assert.Equal("/This/Is/A/Nested/Folder/", wanderingProject.Parent.ItemRef);
// Move project to root