Fixing dotnet migrate global.json. This was failing because we were turning global.json into an empty string and trying to construct a directory for it. The fix was to detect this and transform it into a . directory. Migrate is already respecting the projects node in global.json.
This commit is contained in:
parent
908b6515cb
commit
cdf91f2f30
11 changed files with 83 additions and 8 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": [
|
||||
"App",
|
||||
"App.Tests"
|
||||
"src",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -364,12 +364,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)
|
||||
{
|
||||
|
@ -392,6 +387,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))
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
// 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 ItMigratesWhenBeingPassedJustGlobalJson()
|
||||
{
|
||||
var solutionDirectory =
|
||||
TestAssetsManager.CreateTestInstance("AppWithPackageNamedAfterFolder").Path;
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(solutionDirectory)
|
||||
.WithForwardingToConsole()
|
||||
.Execute($"migrate global.json")
|
||||
.Should()
|
||||
.Pass();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue