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:
		
					parent
					
						
							
								05b448944c
							
						
					
				
			
			
				commit
				
					
						d0151a6111
					
				
			
		
					 23 changed files with 757 additions and 46 deletions
				
			
		| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <OutputType>Exe</OutputType>
 | 
				
			||||||
 | 
					    <TargetFramework>netcoreapp1.0</TargetFramework>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <ProjectReference Include="src\Lib\Lib.csproj" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
					EndGlobal
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Program
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static void Main(string[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Console.WriteLine("Hello from the main app");
 | 
				
			||||||
 | 
					        Console.WriteLine(Lib.Library.GetMessage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <TargetFramework>netstandard1.4</TargetFramework>
 | 
				
			||||||
 | 
					    <ProjectGuid>{84A45D44-B677-492D-A6DA-B3A71135AB8E}</ProjectGuid>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="NETStandard.Library" Version="1.6" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Lib
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class Library
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static string GetMessage()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return "Message from Lib";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <OutputType>Exe</OutputType>
 | 
				
			||||||
 | 
					    <TargetFramework>netcoreapp1.0</TargetFramework>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,62 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NotLastProjInSrc", "NotLastProjInSrc", "{1C5EE322-7073-4298-A077-B7816B1CE15F}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotLastProjInSrc", "src\NotLastProjInSrc\NotLastProjInSrc.csproj", "{96E9FA7D-FE59-4866-AE1E-F9EC2BB2FC67}"
 | 
				
			||||||
 | 
					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}
 | 
				
			||||||
 | 
							{1C5EE322-7073-4298-A077-B7816B1CE15F} = {7B86CE74-F620-4B32-99FE-82D40F8D6BF2}
 | 
				
			||||||
 | 
							{96E9FA7D-FE59-4866-AE1E-F9EC2BB2FC67} = {1C5EE322-7073-4298-A077-B7816B1CE15F}
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
					EndGlobal
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Program
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static void Main(string[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Console.WriteLine("Hello from the main app");
 | 
				
			||||||
 | 
					        Console.WriteLine(Lib.Library.GetMessage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <TargetFramework>netstandard1.4</TargetFramework>
 | 
				
			||||||
 | 
					    <ProjectGuid>{84A45D44-B677-492D-A6DA-B3A71135AB8E}</ProjectGuid>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="NETStandard.Library" Version="1.6" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Lib
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class Library
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static string GetMessage()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return "Message from Lib";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <OutputType>Exe</OutputType>
 | 
				
			||||||
 | 
					    <TargetFramework>netcoreapp1.0</TargetFramework>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,53 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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(NestedProjects) = preSolution
 | 
				
			||||||
 | 
							{EAB71280-AF32-4531-8703-43CDBA261AA3} = {7B86CE74-F620-4B32-99FE-82D40F8D6BF2}
 | 
				
			||||||
 | 
							{84A45D44-B677-492D-A6DA-B3A71135AB8E} = {EAB71280-AF32-4531-8703-43CDBA261AA3}
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
					EndGlobal
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Program
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static void Main(string[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Console.WriteLine("Hello from the main app");
 | 
				
			||||||
 | 
					        Console.WriteLine(Lib.Library.GetMessage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <TargetFramework>netstandard1.4</TargetFramework>
 | 
				
			||||||
 | 
					    <ProjectGuid>{84A45D44-B677-492D-A6DA-B3A71135AB8E}</ProjectGuid>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="**\*.cs" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="NETStandard.Library" Version="1.6" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Lib
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class Library
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static string GetMessage()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return "Message from Lib";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -7,5 +7,6 @@ namespace Microsoft.DotNet.Cli.Sln.Internal
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public const string CPSProjectTypeGuid = "{13B669BE-BB05-4DDF-9536-439F39A36129}";
 | 
					        public const string CPSProjectTypeGuid = "{13B669BE-BB05-4DDF-9536-439F39A36129}";
 | 
				
			||||||
        public const string CSharpProjectTypeGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
 | 
					        public const string CSharpProjectTypeGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
 | 
				
			||||||
 | 
					        public const string SolutionFolderGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										43
									
								
								src/dotnet/SlnProjectCollectionExtensions.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/dotnet/SlnProjectCollectionExtensions.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					// Copyright (c) .NET Foundation and contributors. All rights reserved.
 | 
				
			||||||
 | 
					// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Microsoft.DotNet.Cli.Sln.Internal;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Microsoft.DotNet.Tools.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public static class SlnProjectCollectionExtensions
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static HashSet<string> GetReferencedSolutionFolders(this SlnProjectCollection projects)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var referencedSolutionFolders = new HashSet<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var solutionFolderProjects = projects
 | 
				
			||||||
 | 
					                .Where(p => p.TypeGuid == ProjectTypeGuids.SolutionFolderGuid)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (solutionFolderProjects.Any())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var nonSolutionFolderProjects = projects
 | 
				
			||||||
 | 
					                    .Where(p => p.TypeGuid != ProjectTypeGuids.SolutionFolderGuid)
 | 
				
			||||||
 | 
					                    .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                foreach (var project in nonSolutionFolderProjects)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var solutionFolders = project.GetSolutionFoldersFromProject();
 | 
				
			||||||
 | 
					                    foreach (var solutionFolder in solutionFolders)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (!referencedSolutionFolders.Contains(solutionFolder))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            referencedSolutionFolders.Add(solutionFolder);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return referencedSolutionFolders;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										28
									
								
								src/dotnet/SlnProjectExtensions.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/dotnet/SlnProjectExtensions.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					// Copyright (c) .NET Foundation and contributors. All rights reserved.
 | 
				
			||||||
 | 
					// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Microsoft.DotNet.Cli.Sln.Internal;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Microsoft.DotNet.Tools.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public static class SlnProjectExtensions
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static IList<string> GetSolutionFoldersFromProject(this SlnProject project)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var currentDirString = $".{Path.DirectorySeparatorChar}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var directoryPath = Path.GetDirectoryName(project.FilePath);
 | 
				
			||||||
 | 
					            if (directoryPath.StartsWith(currentDirString))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                directoryPath = directoryPath.Substring(currentDirString.Length);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return directoryPath.StartsWith("..")
 | 
				
			||||||
 | 
					                ? new List<string>()
 | 
				
			||||||
 | 
					                : new List<string>(directoryPath.Split(Path.DirectorySeparatorChar));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -106,6 +106,8 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToSolution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                AddDefaultBuildConfigurations(slnFile, slnProject);
 | 
					                AddDefaultBuildConfigurations(slnFile, slnProject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                AddSolutionFolders(slnFile, slnProject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                slnFile.Projects.Add(slnProject);
 | 
					                slnFile.Projects.Add(slnProject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Reporter.Output.WriteLine(
 | 
					                Reporter.Output.WriteLine(
 | 
				
			||||||
| 
						 | 
					@ -168,5 +170,39 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToSolution
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void AddSolutionFolders(SlnFile slnFile, SlnProject slnProject)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var solutionFolders = slnProject.GetSolutionFoldersFromProject();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (solutionFolders.Any())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var nestedProjectsSection = slnFile.Sections.GetOrCreateSection(
 | 
				
			||||||
 | 
					                    "NestedProjects",
 | 
				
			||||||
 | 
					                    SlnSectionType.PreProcess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                string parentDirGuid = null;
 | 
				
			||||||
 | 
					                foreach (var dir in solutionFolders)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var solutionFolder = new SlnProject
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Id = Guid.NewGuid().ToString("B").ToUpper(),
 | 
				
			||||||
 | 
					                        TypeGuid = ProjectTypeGuids.SolutionFolderGuid,
 | 
				
			||||||
 | 
					                        Name = dir,
 | 
				
			||||||
 | 
					                        FilePath = dir
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    slnFile.Projects.Add(solutionFolder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (parentDirGuid != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        nestedProjectsSection.Properties[solutionFolder.Id] = parentDirGuid;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    parentDirGuid = solutionFolder.Id;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                nestedProjectsSection.Properties[slnProject.Id] = parentDirGuid;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@ using Microsoft.DotNet.Cli.Sln.Internal;
 | 
				
			||||||
using Microsoft.DotNet.Cli.Utils;
 | 
					using Microsoft.DotNet.Cli.Utils;
 | 
				
			||||||
using Microsoft.DotNet.Tools.Common;
 | 
					using Microsoft.DotNet.Tools.Common;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.IO;
 | 
					using System.IO;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,6 +52,8 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            RemoveEmptyConfigurationSections(slnFile);
 | 
					            RemoveEmptyConfigurationSections(slnFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            RemoveEmptySolutionFolders(slnFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (slnChanged)
 | 
					            if (slnChanged)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                slnFile.Write();
 | 
					                slnFile.Write();
 | 
				
			||||||
| 
						 | 
					@ -82,6 +85,15 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        slnFile.ProjectConfigurationsSection.Remove(buildConfigsToRemove);
 | 
					                        slnFile.ProjectConfigurationsSection.Remove(buildConfigsToRemove);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var nestedProjectsSection = slnFile.Sections.GetSection(
 | 
				
			||||||
 | 
					                        "NestedProjects",
 | 
				
			||||||
 | 
					                        SlnSectionType.PreProcess);
 | 
				
			||||||
 | 
					                    if (nestedProjectsSection != null && nestedProjectsSection.Properties.ContainsKey(slnProject.Id))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        nestedProjectsSection.Properties.Remove(slnProject.Id);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    slnFile.Projects.Remove(slnProject);
 | 
					                    slnFile.Projects.Remove(slnProject);
 | 
				
			||||||
                    Reporter.Output.WriteLine(
 | 
					                    Reporter.Output.WriteLine(
 | 
				
			||||||
                        string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, slnProject.FilePath));
 | 
					                        string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, slnProject.FilePath));
 | 
				
			||||||
| 
						 | 
					@ -110,5 +122,35 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void RemoveEmptySolutionFolders(SlnFile slnFile)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var referencedSolutionFolders = slnFile.Projects.GetReferencedSolutionFolders();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var solutionFolderProjects = slnFile.Projects
 | 
				
			||||||
 | 
					                .Where(p => p.TypeGuid == ProjectTypeGuids.SolutionFolderGuid)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (solutionFolderProjects.Any())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var nestedProjectsSection = slnFile.Sections.GetSection(
 | 
				
			||||||
 | 
					                    "NestedProjects",
 | 
				
			||||||
 | 
					                    SlnSectionType.PreProcess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                foreach (var solutionFolderProject in solutionFolderProjects)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (!referencedSolutionFolders.Contains(solutionFolderProject.Name))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        slnFile.Projects.Remove(solutionFolderProject);
 | 
				
			||||||
 | 
					                        nestedProjectsSection.Properties.Remove(solutionFolderProject.Id);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (nestedProjectsSection.IsEmpty)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    slnFile.Sections.Remove(nestedProjectsSection);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,9 @@ VisualStudioVersion = 15.0.26006.2
 | 
				
			||||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
					MinimumVisualStudioVersion = 10.0.40219.1
 | 
				
			||||||
Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
 | 
					Project(""{9A19103F-16F7-4668-BE54-9A1E7A4F7556}"") = ""App"", ""App\App.csproj"", ""{7072A694-548F-4CAE-A58F-12D257D5F486}""
 | 
				
			||||||
EndProject
 | 
					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
 | 
					EndProject
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
						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|x64.Build.0 = Release|x64
 | 
				
			||||||
		{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
 | 
							{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.ActiveCfg = Release|x86
 | 
				
			||||||
		{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
 | 
							{7072A694-548F-4CAE-A58F-12D257D5F486}.Release|x86.Build.0 = Release|x86
 | 
				
			||||||
		__PROJECTGUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
							__LIB_PROJECT_GUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
							__LIB_PROJECT_GUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Debug|x64.ActiveCfg = Debug|x64
 | 
							__LIB_PROJECT_GUID__.Debug|x64.ActiveCfg = Debug|x64
 | 
				
			||||||
		__PROJECTGUID__.Debug|x64.Build.0 = Debug|x64
 | 
							__LIB_PROJECT_GUID__.Debug|x64.Build.0 = Debug|x64
 | 
				
			||||||
		__PROJECTGUID__.Debug|x86.ActiveCfg = Debug|x86
 | 
							__LIB_PROJECT_GUID__.Debug|x86.ActiveCfg = Debug|x86
 | 
				
			||||||
		__PROJECTGUID__.Debug|x86.Build.0 = Debug|x86
 | 
							__LIB_PROJECT_GUID__.Debug|x86.Build.0 = Debug|x86
 | 
				
			||||||
		__PROJECTGUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
							__LIB_PROJECT_GUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Release|Any CPU.Build.0 = Release|Any CPU
 | 
							__LIB_PROJECT_GUID__.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Release|x64.ActiveCfg = Release|x64
 | 
							__LIB_PROJECT_GUID__.Release|x64.ActiveCfg = Release|x64
 | 
				
			||||||
		__PROJECTGUID__.Release|x64.Build.0 = Release|x64
 | 
							__LIB_PROJECT_GUID__.Release|x64.Build.0 = Release|x64
 | 
				
			||||||
		__PROJECTGUID__.Release|x86.ActiveCfg = Release|x86
 | 
							__LIB_PROJECT_GUID__.Release|x86.ActiveCfg = Release|x86
 | 
				
			||||||
		__PROJECTGUID__.Release|x86.Build.0 = Release|x86
 | 
							__LIB_PROJECT_GUID__.Release|x86.Build.0 = Release|x86
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(SolutionProperties) = preSolution
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
		HideSolutionNode = FALSE
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
						GlobalSection(NestedProjects) = preSolution
 | 
				
			||||||
 | 
							__LIB_PROJECT_GUID__ = __LIB_FOLDER_GUID__
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
EndGlobal
 | 
					EndGlobal
 | 
				
			||||||
";
 | 
					";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,7 +88,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 | 
				
			||||||
# Visual Studio 15
 | 
					# Visual Studio 15
 | 
				
			||||||
VisualStudioVersion = 15.0.26006.2
 | 
					VisualStudioVersion = 15.0.26006.2
 | 
				
			||||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
					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
 | 
					EndProject
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
						GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
				
			||||||
| 
						 | 
					@ -95,18 +102,79 @@ Global
 | 
				
			||||||
		Release|x86 = Release|x86
 | 
							Release|x86 = Release|x86
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
						GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
				
			||||||
		__PROJECTGUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
							__LIB_PROJECT_GUID__.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
							__LIB_PROJECT_GUID__.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Debug|x64.ActiveCfg = Debug|x64
 | 
							__LIB_PROJECT_GUID__.Debug|x64.ActiveCfg = Debug|x64
 | 
				
			||||||
		__PROJECTGUID__.Debug|x64.Build.0 = Debug|x64
 | 
							__LIB_PROJECT_GUID__.Debug|x64.Build.0 = Debug|x64
 | 
				
			||||||
		__PROJECTGUID__.Debug|x86.ActiveCfg = Debug|x86
 | 
							__LIB_PROJECT_GUID__.Debug|x86.ActiveCfg = Debug|x86
 | 
				
			||||||
		__PROJECTGUID__.Debug|x86.Build.0 = Debug|x86
 | 
							__LIB_PROJECT_GUID__.Debug|x86.Build.0 = Debug|x86
 | 
				
			||||||
		__PROJECTGUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
							__LIB_PROJECT_GUID__.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Release|Any CPU.Build.0 = Release|Any CPU
 | 
							__LIB_PROJECT_GUID__.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
		__PROJECTGUID__.Release|x64.ActiveCfg = Release|x64
 | 
							__LIB_PROJECT_GUID__.Release|x64.ActiveCfg = Release|x64
 | 
				
			||||||
		__PROJECTGUID__.Release|x64.Build.0 = Release|x64
 | 
							__LIB_PROJECT_GUID__.Release|x64.Build.0 = Release|x64
 | 
				
			||||||
		__PROJECTGUID__.Release|x86.ActiveCfg = Release|x86
 | 
							__LIB_PROJECT_GUID__.Release|x86.ActiveCfg = Release|x86
 | 
				
			||||||
		__PROJECTGUID__.Release|x86.Build.0 = 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
 | 
						EndGlobalSection
 | 
				
			||||||
EndGlobal
 | 
					EndGlobal
 | 
				
			||||||
";
 | 
					";
 | 
				
			||||||
| 
						 | 
					@ -253,6 +321,28 @@ EndGlobal
 | 
				
			||||||
            cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
 | 
					            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]
 | 
					        [Theory]
 | 
				
			||||||
        [InlineData("TestAppWithSlnAndCsprojFiles", ExpectedSlnFileAfterAddingLibProj, "")]
 | 
					        [InlineData("TestAppWithSlnAndCsprojFiles", ExpectedSlnFileAfterAddingLibProj, "")]
 | 
				
			||||||
        [InlineData("TestAppWithSlnAndCsprojProjectGuidFiles", ExpectedSlnFileAfterAddingLibProj, "{84A45D44-B677-492D-A6DA-B3A71135AB8E}")]
 | 
					        [InlineData("TestAppWithSlnAndCsprojProjectGuidFiles", ExpectedSlnFileAfterAddingLibProj, "{84A45D44-B677-492D-A6DA-B3A71135AB8E}")]
 | 
				
			||||||
| 
						 | 
					@ -277,19 +367,11 @@ EndGlobal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var slnPath = Path.Combine(projectDirectory, "App.sln");
 | 
					            var slnPath = Path.Combine(projectDirectory, "App.sln");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (string.IsNullOrEmpty(expectedProjectGuid))
 | 
					            var expectedSlnContents = GetExpectedSlnContents(
 | 
				
			||||||
            {
 | 
					                slnPath,
 | 
				
			||||||
                var slnFile = SlnFile.Read(slnPath);
 | 
					                expectedSlnContentsTemplate,
 | 
				
			||||||
                var matchingProjects = slnFile.Projects
 | 
					                expectedProjectGuid);
 | 
				
			||||||
                    .Where((p) => p.Name == "Lib")
 | 
					 | 
				
			||||||
                    .ToList();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                matchingProjects.Count.Should().Be(1);
 | 
					 | 
				
			||||||
                var slnProject = matchingProjects[0];
 | 
					 | 
				
			||||||
                expectedProjectGuid = slnProject.Id;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var expectedSlnContents = expectedSlnContentsTemplate.Replace("__PROJECTGUID__", expectedProjectGuid);
 | 
					 | 
				
			||||||
            File.ReadAllText(slnPath)
 | 
					            File.ReadAllText(slnPath)
 | 
				
			||||||
                .Should().BeVisuallyEquivalentTo(expectedSlnContents);
 | 
					                .Should().BeVisuallyEquivalentTo(expectedSlnContents);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -317,7 +399,7 @@ EndGlobal
 | 
				
			||||||
            cmd.StdErr.Should().BeEmpty();
 | 
					            cmd.StdErr.Should().BeEmpty();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //ISSUE: https://github.com/dotnet/sdk/issues/545
 | 
					        //ISSUE: https://github.com/dotnet/cli/issues/5205
 | 
				
			||||||
        //[Theory]
 | 
					        //[Theory]
 | 
				
			||||||
        //[InlineData("TestAppWithSlnAndCsprojFiles")]
 | 
					        //[InlineData("TestAppWithSlnAndCsprojFiles")]
 | 
				
			||||||
        //[InlineData("TestAppWithSlnAndCsprojProjectGuidFiles")]
 | 
					        //[InlineData("TestAppWithSlnAndCsprojProjectGuidFiles")]
 | 
				
			||||||
| 
						 | 
					@ -410,5 +492,41 @@ EndGlobal
 | 
				
			||||||
            File.ReadAllText(slnFullPath)
 | 
					            File.ReadAllText(slnFullPath)
 | 
				
			||||||
                .Should().BeVisuallyEquivalentTo(contentBefore);
 | 
					                .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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,24 +60,27 @@ namespace Microsoft.DotNet.Migration.Tests
 | 
				
			||||||
                .Execute($"restore \"{solutionRelPath}\"")
 | 
					                .Execute($"restore \"{solutionRelPath}\"")
 | 
				
			||||||
                .Should().Pass();
 | 
					                .Should().Pass();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //ISSUE: https://github.com/dotnet/sdk/issues/545
 | 
					            //ISSUE: https://github.com/dotnet/cli/issues/5205
 | 
				
			||||||
            //new DotnetCommand()
 | 
					            //new DotnetCommand()
 | 
				
			||||||
            //    .WithWorkingDirectory(projectDirectory)
 | 
					            //    .WithWorkingDirectory(projectDirectory)
 | 
				
			||||||
            //    .Execute($"build \"{solutionRelPath}\"")
 | 
					            //    .Execute($"build \"{solutionRelPath}\"")
 | 
				
			||||||
            //    .Should().Pass();
 | 
					            //    .Should().Pass();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
 | 
					            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.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
 | 
				
			||||||
            slnProject.FilePath.Should().Be("TestApp.csproj");
 | 
					            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.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
 | 
				
			||||||
            slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
 | 
					            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.TypeGuid.Should().Be(subdirProjectTypeGuid);
 | 
				
			||||||
            slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
 | 
					            slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,6 +67,97 @@ VisualStudioVersion = 15.0.26006.2
 | 
				
			||||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
					MinimumVisualStudioVersion = 10.0.40219.1
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
EndGlobal
 | 
					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]
 | 
					        [Theory]
 | 
				
			||||||
| 
						 | 
					@ -341,8 +432,7 @@ Project reference `idontexisteither.csproj` could not be found.";
 | 
				
			||||||
                .Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemove);
 | 
					                .Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemove);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //ISSUE: https://github.com/dotnet/sdk/issues/545
 | 
					        [Fact]
 | 
				
			||||||
        //[Fact]
 | 
					 | 
				
			||||||
        public void WhenReferenceIsRemovedSlnBuilds()
 | 
					        public void WhenReferenceIsRemovedSlnBuilds()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var projectDirectory = TestAssets
 | 
					            var projectDirectory = TestAssets
 | 
				
			||||||
| 
						 | 
					@ -408,5 +498,49 @@ Project reference `idontexisteither.csproj` could not be found.";
 | 
				
			||||||
            File.ReadAllText(solutionPath)
 | 
					            File.ReadAllText(solutionPath)
 | 
				
			||||||
                .Should().BeVisuallyEquivalentTo(ExpectedSlnContentsAfterRemoveAllProjects);
 | 
					                .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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue