diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs new file mode 100644 index 000000000..c56978bf5 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace App.Tests +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json new file mode 100644 index 000000000..91b0a9ae6 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithSlnAndXprojRefs/TestApp/TestAssets/TestAsset/project.json @@ -0,0 +1,15 @@ +{ + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "portable-net451+win8" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs index ad29bec23..07f68b5b8 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs @@ -51,6 +51,35 @@ namespace Microsoft.DotNet.Migration.Tests "PJAppWithSlnAndXprojRefs"); } + [Fact] + public void ItOnlyMigratesProjectsInTheSlnFile() + { + var projectDirectory = TestAssets + .Get("NonRestoredTestProjects", "PJAppWithSlnAndXprojRefs") + .CreateInstance() + .WithSourceFiles() + .Root; + + var solutionRelPath = Path.Combine("TestApp", "TestApp.sln"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute($"migrate \"{solutionRelPath}\"") + .Should().Pass(); + + new DirectoryInfo(projectDirectory.FullName) + .Should().HaveFiles(new [] + { + Path.Combine("TestApp", "TestApp.csproj"), + Path.Combine("TestLibrary", "TestLibrary.csproj"), + Path.Combine("TestApp", "src", "subdir", "subdir.csproj"), + Path.Combine("TestApp", "TestAssets", "TestAsset", "project.json") + }); + + new DirectoryInfo(projectDirectory.FullName) + .Should().NotHaveFile(Path.Combine("TestApp", "TestAssets", "TestAsset", "TestAsset.csproj")); + } + [Fact] public void WhenDirectoryAlreadyContainsCsprojFileItMigratesAndBuildsSln() {