2016-12-20 23:04:01 +00:00
|
|
|
|
// 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 FluentAssertions;
|
|
|
|
|
using Microsoft.DotNet.Cli.Sln.Internal;
|
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2017-01-12 01:06:03 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2016-12-20 23:04:01 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Migration.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenThatIWantToMigrateSolutions : TestBase
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItMigratesAndBuildsSln()
|
|
|
|
|
{
|
|
|
|
|
MigrateAndBuild(
|
|
|
|
|
"NonRestoredTestProjects",
|
2017-01-05 22:04:57 +00:00
|
|
|
|
"PJAppWithSlnAndXprojRefs");
|
2016-12-20 23:04:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-12 01:06:03 +00:00
|
|
|
|
private void MigrateAndBuild(string groupName, string projectName, [CallerMemberName] string callingMethod = "", string identifier = "")
|
2016-12-20 23:04:01 +00:00
|
|
|
|
{
|
|
|
|
|
var projectDirectory = TestAssets
|
|
|
|
|
.Get(groupName, projectName)
|
2017-01-12 01:06:03 +00:00
|
|
|
|
.CreateInstance(callingMethod: callingMethod, identifier: identifier)
|
2016-12-20 23:04:01 +00:00
|
|
|
|
.WithSourceFiles()
|
2017-01-26 07:48:31 +00:00
|
|
|
|
.WithEmptyGlobalJson()
|
2016-12-20 23:04:01 +00:00
|
|
|
|
.Root;
|
|
|
|
|
|
|
|
|
|
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute($"migrate \"{solutionRelPath}\"")
|
|
|
|
|
.Should().Pass();
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2017-01-03 21:06:51 +00:00
|
|
|
|
.Execute($"restore \"{solutionRelPath}\"")
|
2016-12-20 23:04:01 +00:00
|
|
|
|
.Should().Pass();
|
|
|
|
|
|
2017-03-08 19:33:27 +00:00
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute($"build \"{solutionRelPath}\"")
|
|
|
|
|
.Should().Pass();
|
2016-12-20 23:04:01 +00:00
|
|
|
|
|
|
|
|
|
SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
|
2017-01-22 22:40:00 +00:00
|
|
|
|
|
2017-01-05 04:32:09 +00:00
|
|
|
|
var nonSolutionFolderProjects = slnFile.Projects
|
|
|
|
|
.Where(p => p.TypeGuid != ProjectTypeGuids.SolutionFolderGuid);
|
2016-12-20 23:04:01 +00:00
|
|
|
|
|
2017-01-05 04:32:09 +00:00
|
|
|
|
nonSolutionFolderProjects.Count().Should().Be(3);
|
|
|
|
|
|
|
|
|
|
var slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestApp").Single();
|
2016-12-20 23:04:01 +00:00
|
|
|
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
|
|
|
|
slnProject.FilePath.Should().Be("TestApp.csproj");
|
|
|
|
|
|
2017-01-05 04:32:09 +00:00
|
|
|
|
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "TestLibrary").Single();
|
2016-12-20 23:04:01 +00:00
|
|
|
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
|
|
|
|
slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
|
|
|
|
|
|
2017-01-05 04:32:09 +00:00
|
|
|
|
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "subdir").Single();
|
2018-03-15 01:21:50 +00:00
|
|
|
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
2016-12-20 23:04:01 +00:00
|
|
|
|
slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|