Add/remove solution items based on directory structure (#5197)

* WIP support solution folders for dotnet add and remove

* Add/remove solution folders based on directory hierarchy

* Fix tests

* Disable the solution building tests

* Address PR comments

* Fix a build break due to a new tool version used in the build

* Create SlnProjectExtensions and SlnProjectCollectionExtensions per PR comments
This commit is contained in:
Justin Goshi 2017-01-04 18:32:09 -10:00 committed by GitHub
parent 05b448944c
commit d0151a6111
23 changed files with 757 additions and 46 deletions

View file

@ -35,7 +35,9 @@ VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
EndProject
Project(""{13B669BE-BB05-4DDF-9536-439F39A36129}"") = ""Lib"", ""Lib\Lib.csproj"", ""__PROJECTGUID__""
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""Lib"", ""Lib"", ""__LIB_FOLDER_GUID__""
EndProject
Project(""{13B669BE-BB05-4DDF-9536-439F39A36129}"") = ""Lib"", ""Lib\Lib.csproj"", ""__LIB_PROJECT_GUID__""
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -59,22 +61,25 @@ Global
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
__PROJECTGUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
__PROJECTGUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
__PROJECTGUID__.Debug|x64.ActiveCfg = Debug|x64
__PROJECTGUID__.Debug|x64.Build.0 = Debug|x64
__PROJECTGUID__.Debug|x86.ActiveCfg = Debug|x86
__PROJECTGUID__.Debug|x86.Build.0 = Debug|x86
__PROJECTGUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
__PROJECTGUID__.Release|Any CPU.Build.0 = Release|Any CPU
__PROJECTGUID__.Release|x64.ActiveCfg = Release|x64
__PROJECTGUID__.Release|x64.Build.0 = Release|x64
__PROJECTGUID__.Release|x86.ActiveCfg = Release|x86
__PROJECTGUID__.Release|x86.Build.0 = Release|x86
__LIB_PROJECT_GUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|x64.ActiveCfg = Debug|x64
__LIB_PROJECT_GUID__.Debug|x64.Build.0 = Debug|x64
__LIB_PROJECT_GUID__.Debug|x86.ActiveCfg = Debug|x86
__LIB_PROJECT_GUID__.Debug|x86.Build.0 = Debug|x86
__LIB_PROJECT_GUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
__LIB_PROJECT_GUID__.Release|Any CPU.Build.0 = Release|Any CPU
__LIB_PROJECT_GUID__.Release|x64.ActiveCfg = Release|x64
__LIB_PROJECT_GUID__.Release|x64.Build.0 = Release|x64
__LIB_PROJECT_GUID__.Release|x86.ActiveCfg = Release|x86
__LIB_PROJECT_GUID__.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
__LIB_PROJECT_GUID__ = __LIB_FOLDER_GUID__
EndGlobalSection
EndGlobal
";
@ -83,7 +88,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{13B669BE-BB05-4DDF-9536-439F39A36129}"") = ""Lib"", ""Lib\Lib.csproj"", ""__PROJECTGUID__""
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""Lib"", ""Lib"", ""__LIB_FOLDER_GUID__""
EndProject
Project(""{13B669BE-BB05-4DDF-9536-439F39A36129}"") = ""Lib"", ""Lib\Lib.csproj"", ""__LIB_PROJECT_GUID__""
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -95,18 +102,79 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
__PROJECTGUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
__PROJECTGUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
__PROJECTGUID__.Debug|x64.ActiveCfg = Debug|x64
__PROJECTGUID__.Debug|x64.Build.0 = Debug|x64
__PROJECTGUID__.Debug|x86.ActiveCfg = Debug|x86
__PROJECTGUID__.Debug|x86.Build.0 = Debug|x86
__PROJECTGUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
__PROJECTGUID__.Release|Any CPU.Build.0 = Release|Any CPU
__PROJECTGUID__.Release|x64.ActiveCfg = Release|x64
__PROJECTGUID__.Release|x64.Build.0 = Release|x64
__PROJECTGUID__.Release|x86.ActiveCfg = Release|x86
__PROJECTGUID__.Release|x86.Build.0 = Release|x86
__LIB_PROJECT_GUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|x64.ActiveCfg = Debug|x64
__LIB_PROJECT_GUID__.Debug|x64.Build.0 = Debug|x64
__LIB_PROJECT_GUID__.Debug|x86.ActiveCfg = Debug|x86
__LIB_PROJECT_GUID__.Debug|x86.Build.0 = Debug|x86
__LIB_PROJECT_GUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
__LIB_PROJECT_GUID__.Release|Any CPU.Build.0 = Release|Any CPU
__LIB_PROJECT_GUID__.Release|x64.ActiveCfg = Release|x64
__LIB_PROJECT_GUID__.Release|x64.Build.0 = Release|x64
__LIB_PROJECT_GUID__.Release|x86.ActiveCfg = Release|x86
__LIB_PROJECT_GUID__.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
__LIB_PROJECT_GUID__ = __LIB_FOLDER_GUID__
EndGlobalSection
EndGlobal
";
private const string ExpectedSlnFileAfterAddingNestedProj = @"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
EndProject
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""src"", ""src"", ""__SRC_FOLDER_GUID__""
EndProject
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""Lib"", ""Lib"", ""__LIB_FOLDER_GUID__""
EndProject
Project(""{13B669BE-BB05-4DDF-9536-439F39A36129}"") = ""Lib"", ""src\Lib\Lib.csproj"", ""__LIB_PROJECT_GUID__""
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
__LIB_PROJECT_GUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
__LIB_PROJECT_GUID__.Debug|x64.ActiveCfg = Debug|x64
__LIB_PROJECT_GUID__.Debug|x64.Build.0 = Debug|x64
__LIB_PROJECT_GUID__.Debug|x86.ActiveCfg = Debug|x86
__LIB_PROJECT_GUID__.Debug|x86.Build.0 = Debug|x86
__LIB_PROJECT_GUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
__LIB_PROJECT_GUID__.Release|Any CPU.Build.0 = Release|Any CPU
__LIB_PROJECT_GUID__.Release|x64.ActiveCfg = Release|x64
__LIB_PROJECT_GUID__.Release|x64.Build.0 = Release|x64
__LIB_PROJECT_GUID__.Release|x86.ActiveCfg = Release|x86
__LIB_PROJECT_GUID__.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
__LIB_FOLDER_GUID__ = __SRC_FOLDER_GUID__
__LIB_PROJECT_GUID__ = __LIB_FOLDER_GUID__
EndGlobalSection
EndGlobal
";
@ -253,6 +321,28 @@ EndGlobal
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
public void WhenNestedProjectIsAddedSolutionFoldersAreCreated()
{
var projectDirectory = TestAssets
.Get("TestAppWithSlnAndCsprojInSubDir")
.CreateInstance()
.WithSourceFiles()
.Root
.FullName;
var projectToAdd = Path.Combine("src", "Lib", "Lib.csproj");
var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}");
cmd.Should().Pass();
var slnPath = Path.Combine(projectDirectory, "App.sln");
var expectedSlnContents = GetExpectedSlnContents(slnPath, ExpectedSlnFileAfterAddingNestedProj);
File.ReadAllText(slnPath)
.Should().BeVisuallyEquivalentTo(expectedSlnContents);
}
[Theory]
[InlineData("TestAppWithSlnAndCsprojFiles", ExpectedSlnFileAfterAddingLibProj, "")]
[InlineData("TestAppWithSlnAndCsprojProjectGuidFiles", ExpectedSlnFileAfterAddingLibProj, "{84A45D44-B677-492D-A6DA-B3A71135AB8E}")]
@ -277,19 +367,11 @@ EndGlobal
var slnPath = Path.Combine(projectDirectory, "App.sln");
if (string.IsNullOrEmpty(expectedProjectGuid))
{
var slnFile = SlnFile.Read(slnPath);
var matchingProjects = slnFile.Projects
.Where((p) => p.Name == "Lib")
.ToList();
var expectedSlnContents = GetExpectedSlnContents(
slnPath,
expectedSlnContentsTemplate,
expectedProjectGuid);
matchingProjects.Count.Should().Be(1);
var slnProject = matchingProjects[0];
expectedProjectGuid = slnProject.Id;
}
var expectedSlnContents = expectedSlnContentsTemplate.Replace("__PROJECTGUID__", expectedProjectGuid);
File.ReadAllText(slnPath)
.Should().BeVisuallyEquivalentTo(expectedSlnContents);
}
@ -317,7 +399,7 @@ EndGlobal
cmd.StdErr.Should().BeEmpty();
}
//ISSUE: https://github.com/dotnet/sdk/issues/545
//ISSUE: https://github.com/dotnet/cli/issues/5205
//[Theory]
//[InlineData("TestAppWithSlnAndCsprojFiles")]
//[InlineData("TestAppWithSlnAndCsprojProjectGuidFiles")]
@ -410,5 +492,41 @@ EndGlobal
File.ReadAllText(slnFullPath)
.Should().BeVisuallyEquivalentTo(contentBefore);
}
private string GetExpectedSlnContents(
string slnPath,
string slnTemplate,
string expectedLibProjectGuid = null)
{
var slnFile = SlnFile.Read(slnPath);
if (string.IsNullOrEmpty(expectedLibProjectGuid))
{
var matchingProjects = slnFile.Projects
.Where((p) => p.FilePath.EndsWith("Lib.csproj"))
.ToList();
matchingProjects.Count.Should().Be(1);
var slnProject = matchingProjects[0];
expectedLibProjectGuid = slnProject.Id;
}
var slnContents = slnTemplate.Replace("__LIB_PROJECT_GUID__", expectedLibProjectGuid);
var matchingLibFolder = slnFile.Projects
.Where((p) => p.FilePath == "Lib")
.ToList();
matchingLibFolder.Count.Should().Be(1);
slnContents = slnContents.Replace("__LIB_FOLDER_GUID__", matchingLibFolder[0].Id);
var matchingSrcFolder = slnFile.Projects
.Where((p) => p.FilePath == "src")
.ToList();
if (matchingSrcFolder.Count == 1)
{
slnContents = slnContents.Replace("__SRC_FOLDER_GUID__", matchingSrcFolder[0].Id);
}
return slnContents;
}
}
}

View file

@ -60,24 +60,27 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute($"restore \"{solutionRelPath}\"")
.Should().Pass();
//ISSUE: https://github.com/dotnet/sdk/issues/545
//ISSUE: https://github.com/dotnet/cli/issues/5205
//new DotnetCommand()
// .WithWorkingDirectory(projectDirectory)
// .Execute($"build \"{solutionRelPath}\"")
// .Should().Pass();
SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
slnFile.Projects.Count.Should().Be(3);
var nonSolutionFolderProjects = slnFile.Projects
.Where(p => p.TypeGuid != ProjectTypeGuids.SolutionFolderGuid);
var slnProject = slnFile.Projects.Where((p) => p.Name == "TestApp").Single();
nonSolutionFolderProjects.Count().Should().Be(3);
var slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestApp").Single();
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
slnProject.FilePath.Should().Be("TestApp.csproj");
slnProject = slnFile.Projects.Where((p) => p.Name == "TestLibrary").Single();
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestLibrary").Single();
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
slnProject = slnFile.Projects.Where((p) => p.Name == "subdir").Single();
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "subdir").Single();
slnProject.TypeGuid.Should().Be(subdirProjectTypeGuid);
slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
}

View file

@ -67,6 +67,97 @@ VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Global
EndGlobal
";
private const string ExpectedSlnContentsAfterRemoveNestedProj = @"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
EndProject
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""src"", ""src"", ""{7B86CE74-F620-4B32-99FE-82D40F8D6BF2}""
EndProject
Project(""{2150E333-8FDC-42A3-9474-1A3956D46DE8}"") = ""Lib"", ""Lib"", ""{EAB71280-AF32-4531-8703-43CDBA261AA3}""
EndProject
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""Lib"", ""src\Lib\Lib.csproj"", ""{84A45D44-B677-492D-A6DA-B3A71135AB8E}""
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|x64.ActiveCfg = Debug|x64
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|x64.Build.0 = Debug|x64
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|x86.ActiveCfg = Debug|x86
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Debug|x86.Build.0 = Debug|x86
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|Any CPU.Build.0 = Release|Any CPU
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|x64.ActiveCfg = Release|x64
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|x64.Build.0 = Release|x64
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|x86.ActiveCfg = Release|x86
{84A45D44-B677-492D-A6DA-B3A71135AB8E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EAB71280-AF32-4531-8703-43CDBA261AA3} = {7B86CE74-F620-4B32-99FE-82D40F8D6BF2}
{84A45D44-B677-492D-A6DA-B3A71135AB8E} = {EAB71280-AF32-4531-8703-43CDBA261AA3}
EndGlobalSection
EndGlobal
";
private const string ExpectedSlnContentsAfterRemoveLastNestedProj = @"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.ActiveCfg = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x64.Build.0 = Debug|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.ActiveCfg = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Debug|x86.Build.0 = Debug|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|Any CPU.Build.0 = Release|Any CPU
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.ActiveCfg = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x64.Build.0 = Release|x64
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal
";
[Theory]
@ -341,8 +432,7 @@ Project reference `idontexisteither.csproj` could not be found.";
.Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemove);
}
//ISSUE: https://github.com/dotnet/sdk/issues/545
//[Fact]
[Fact]
public void WhenReferenceIsRemovedSlnBuilds()
{
var projectDirectory = TestAssets
@ -408,5 +498,49 @@ Project reference `idontexisteither.csproj` could not be found.";
File.ReadAllText(solutionPath)
.Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemoveAllProjects);
}
[Fact]
public void WhenNestedProjectIsRemovedItsSolutionFoldersAreRemoved()
{
var projectDirectory = TestAssets
.Get("TestAppWithSlnAndCsprojInSubDirToRemove")
.CreateInstance()
.WithSourceFiles()
.Root
.FullName;
var solutionPath = Path.Combine(projectDirectory, "App.sln");
var projectToRemove = Path.Combine("src", "NotLastProjInSrc", "NotLastProjInSrc.csproj");
var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
cmd.Should().Pass();
File.ReadAllText(solutionPath)
.Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemoveNestedProj);
}
[Fact]
public void WhenFinalNestedProjectIsRemovedSolutionFoldersAreRemoved()
{
var projectDirectory = TestAssets
.Get("TestAppWithSlnAndLastCsprojInSubDirToRemove")
.CreateInstance()
.WithSourceFiles()
.Root
.FullName;
var solutionPath = Path.Combine(projectDirectory, "App.sln");
var projectToRemove = Path.Combine("src", "Lib", "Lib.csproj");
var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
cmd.Should().Pass();
File.ReadAllText(solutionPath)
.Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemoveLastNestedProj);
}
}
}