Skip to content

Commit dd42405

Browse files
committed
feat(solution): remove and re-add project during rename
- Remove project from solution before file operations - Re-add project to solution with new path after rename Closes #22
1 parent 8d008c7 commit dd42405

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/CodingWithCalvin.ProjectRenamifier/Commands/RenamifyProjectCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ private void RenameProject(Project project, DTE2 dte)
8080
var newName = dialog.NewProjectName;
8181
var projectFilePath = project.FullName;
8282

83+
// Remove project from solution before file operations
84+
dte.Solution.Remove(project);
85+
8386
// Update RootNamespace and AssemblyName in .csproj
8487
ProjectFileService.UpdateProjectFile(projectFilePath, currentName, newName);
8588

@@ -89,10 +92,12 @@ private void RenameProject(Project project, DTE2 dte)
8992
// Rename the project file on disk
9093
projectFilePath = ProjectFileService.RenameProjectFile(projectFilePath, newName);
9194

95+
// Re-add project to solution with new path
96+
dte.Solution.AddFromFile(projectFilePath);
97+
9298
// TODO: Implement remaining rename operations
9399
// See open issues for requirements:
94100
// - #21: Rename parent directory if it matches project name
95-
// - #22: Remove and re-add project to solution
96101
// - #23: Update project references
97102
// - #9: Update using statements across solution
98103
// - #11: Solution folder support

0 commit comments

Comments
 (0)