Skip to content

Commit e7b7e4b

Browse files
authored
update
1 parent 6ca1316 commit e7b7e4b

File tree

1 file changed

+4
-3
lines changed
  • src/Cli/dotnet/commands/dotnet-sln/remove

1 file changed

+4
-3
lines changed

src/Cli/dotnet/commands/dotnet-sln/remove/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ private async Task RemoveProjectsAsync(string solutionFileFullPath, IEnumerable<
9393
}
9494
}
9595

96-
// make a copy for safe modification during iteration
97-
SolutionFolderModel[] folders = [..solution.SolutionFolders];
98-
foreach (var folder in folders)
96+
for (int i = 0; i < solution.SolutionFolders.Count; i++)
9997
{
98+
var folder = solution.SolutionFolders[i];
10099
int nonFolderDescendants = 0;
101100
Stack<SolutionFolderModel> stack = new();
102101
stack.Push(folder);
@@ -125,6 +124,8 @@ private async Task RemoveProjectsAsync(string solutionFileFullPath, IEnumerable<
125124
if (nonFolderDescendants == 0)
126125
{
127126
solution.RemoveFolder(folder);
127+
// After removal, adjust index and continue to avoid skipping folders after removal
128+
i--;
128129
}
129130
}
130131

0 commit comments

Comments
 (0)