Merge branch 'rel/1.0.0' into dev/jgoshi/issue5343

This commit is contained in:
Piotr Puszkiewicz 2017-01-20 14:08:49 -08:00 committed by GitHub
commit fe290f1e26
12 changed files with 109 additions and 9 deletions

View file

@ -0,0 +1,12 @@
using System;
namespace App.Tests
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World from Test asset!");
}
}
}

View file

@ -0,0 +1,15 @@
{
"frameworks": {
"netcoreapp1.0": {
"imports": [
"portable-net451+win8"
],
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
}
}
}
}
}

View file

@ -1,6 +1,6 @@
{
"projects": [
"App",
"App.Tests"
"src",
"test"
]
}

View file

@ -386,12 +386,7 @@ namespace Microsoft.DotNet.Tools.Migrate
private IEnumerable<string> GetProjectsFromGlobalJson(string globalJson)
{
if (!File.Exists(globalJson))
{
throw new GracefulException($"Unable to find global settings file at {globalJson}");
}
var searchPaths = ProjectDependencyFinder.GetGlobalPaths(Path.GetDirectoryName(globalJson));
var searchPaths = ProjectDependencyFinder.GetGlobalPaths(GetGlobalJsonDirectory(globalJson));
foreach (var searchPath in searchPaths)
{
@ -414,6 +409,17 @@ namespace Microsoft.DotNet.Tools.Migrate
}
}
private string GetGlobalJsonDirectory(string globalJson)
{
if (!File.Exists(globalJson))
{
throw new GracefulException($"Unable to find global settings file at {globalJson}");
}
var globalJsonDirectory = Path.GetDirectoryName(globalJson);
return string.IsNullOrEmpty(globalJsonDirectory) ? "." : globalJsonDirectory;
}
private IEnumerable<string> GetProjectsFromSolution(string slnPath)
{
if (!File.Exists(slnPath))

View file

@ -0,0 +1,67 @@
// 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.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using System.IO;
using Xunit;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenThatIWantToMigrateAppsUsingGlobalJson : TestBase
{
[Fact]
public void ItMigratesWhenBeingPassedAFullPathToGlobalJson()
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
var globalJsonPath = Path.Combine(solutionDirectory, "global.json");
new TestCommand("dotnet")
.WithForwardingToConsole()
.Execute($"migrate {globalJsonPath}")
.Should()
.Pass();
}
[Fact]
public void WhenUsingGlobalJsonItOnlyMigratesProjectsInTheGlobalJsonNode()
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
var globalJsonPath = Path.Combine(solutionDirectory, "global.json");
new TestCommand("dotnet")
.WithForwardingToConsole()
.Execute($"migrate {globalJsonPath}")
.Should()
.Pass();
new DirectoryInfo(solutionDirectory)
.Should().HaveFiles(new []
{
Path.Combine("src", "App", "App.csproj"),
Path.Combine("test", "App.Tests", "App.Tests.csproj"),
Path.Combine("TestAssets", "TestAsset", "project.json")
});
new DirectoryInfo(solutionDirectory)
.Should().NotHaveFile(Path.Combine("TestAssets", "TestAsset", "TestAsset.csproj"));
}
[Fact]
public void ItMigratesWhenBeingPassedJustGlobalJson()
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
new TestCommand("dotnet")
.WithWorkingDirectory(solutionDirectory)
.WithForwardingToConsole()
.Execute($"migrate global.json")
.Should()
.Pass();
}
}
}

View file

@ -168,7 +168,7 @@ namespace Microsoft.DotNet.Migration.Tests
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
var appProject = Path.Combine(solutionDirectory, "App", "App.csproj");
var appProject = Path.Combine(solutionDirectory, "src", "App", "App.csproj");
MigrateProject(solutionDirectory);