Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static async Task RemoveProjectsAsync(string solutionFileFullPath, IEnum
// If the project is not found, try to find it by name without extension
if (project is null && !Path.HasExtension(projectPath))
{
var projectsMatchByName = solution.SolutionProjects.Where(p => Path.GetFileNameWithoutExtension(p.DisplayName).Equals(projectPath));
var projectsMatchByName = solution.SolutionProjects.Where(p => p.ActualDisplayName.Equals(projectPath));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! p.DisplayName could return null

project = projectsMatchByName.Count() == 1 ? projectsMatchByName.First() : null;
}
// If project is still not found, print error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@ public void WhenNoProjectIsPassedItPrintsErrorAndUsage(string solutionCommand, s
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized("");
}

[Theory]
[InlineData("sln", ".sln")]
[InlineData("solution", ".sln")]
[InlineData("sln", ".slnx")]
[InlineData("solution", ".slnx")]
public void WhenProjectWithoutExtensionIsPassedAndDoesntExistItPrintsError(string solutionCommand, string solutionExtension)
{
var projectDirectory = _testAssetsManager
.CopyTestAsset("TestAppWithSlnAndCsprojFiles", identifier: $"{solutionCommand}GivenDotnetSlnRemove")
.WithSource()
.Path;

var cmd = new DotnetCommand(Log)
.WithWorkingDirectory(projectDirectory)
.Execute(solutionCommand, $"App{solutionExtension}", "remove", "InexistingProjectNameWithoutExtension");

cmd.Should().Pass();
cmd.StdOut.Should().Be(string.Format(CliStrings.ProjectNotFoundInTheSolution, "InexistingProjectNameWithoutExtension"));
}

[Theory]
[InlineData("sln")]
[InlineData("solution")]
Expand Down
Loading