Merge branch 'rel/1.0.0' into dev/jgoshi/issue5343
This commit is contained in:
commit
fe290f1e26
12 changed files with 109 additions and 9 deletions
|
@ -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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": [
|
||||||
|
"portable-net451+win8"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "platform"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"projects": [
|
"projects": [
|
||||||
"App",
|
"src",
|
||||||
"App.Tests"
|
"test"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,12 +386,7 @@ namespace Microsoft.DotNet.Tools.Migrate
|
||||||
|
|
||||||
private IEnumerable<string> GetProjectsFromGlobalJson(string globalJson)
|
private IEnumerable<string> GetProjectsFromGlobalJson(string globalJson)
|
||||||
{
|
{
|
||||||
if (!File.Exists(globalJson))
|
var searchPaths = ProjectDependencyFinder.GetGlobalPaths(GetGlobalJsonDirectory(globalJson));
|
||||||
{
|
|
||||||
throw new GracefulException($"Unable to find global settings file at {globalJson}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var searchPaths = ProjectDependencyFinder.GetGlobalPaths(Path.GetDirectoryName(globalJson));
|
|
||||||
|
|
||||||
foreach (var searchPath in searchPaths)
|
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)
|
private IEnumerable<string> GetProjectsFromSolution(string slnPath)
|
||||||
{
|
{
|
||||||
if (!File.Exists(slnPath))
|
if (!File.Exists(slnPath))
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -168,7 +168,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
{
|
{
|
||||||
var solutionDirectory =
|
var solutionDirectory =
|
||||||
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
|
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
|
||||||
var appProject = Path.Combine(solutionDirectory, "App", "App.csproj");
|
var appProject = Path.Combine(solutionDirectory, "src", "App", "App.csproj");
|
||||||
|
|
||||||
MigrateProject(solutionDirectory);
|
MigrateProject(solutionDirectory);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue