Merge pull request #5541 from livarcocc/wrong_global_json_folders

Changing the order in which search paths are added for migration
This commit is contained in:
Livar 2017-02-01 16:36:56 -08:00 committed by GitHub
commit 260b40456a
12 changed files with 113 additions and 16 deletions

View file

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

View file

@ -0,0 +1,23 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"ProjectA": {
"target": "project"
}
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}

View file

@ -0,0 +1,19 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}

View file

@ -0,0 +1,3 @@
{
"projects": [ "src" ]
}

View file

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

View file

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>ProjectA</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>ProjectA</PackageId>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
</PropertyGroup>
</Project>

View file

@ -0,0 +1 @@
{}

View file

@ -230,10 +230,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration
projectSearchPaths.Add(projectRootDirectory);
var globalPaths = GetGlobalPaths(projectRootDirectory);
projectSearchPaths = projectSearchPaths.Union(globalPaths).ToList();
projectSearchPaths = globalPaths.Union(projectSearchPaths).ToList();
var solutionPaths = GetSolutionPaths(slnFile);
projectSearchPaths = projectSearchPaths.Union(solutionPaths).ToList();
projectSearchPaths = solutionPaths.Union(projectSearchPaths).ToList();
var projects = new Dictionary<string, ProjectDependency>(StringComparer.Ordinal);
@ -328,11 +328,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration
var projectJSONFilePath = Path.Combine(projectDirectory.FullName, "project.json");
var csProjFilePath = Path.Combine(projectDirectory.FullName, $"{projectDirectory.Name}.csproj");
if (File.Exists(projectJSONFilePath) || File.Exists(csProjFilePath))
if (File.Exists(projectJSONFilePath))
{
var project = new ProjectDependency(projectDirectory.Name, projectJSONFilePath);
projects.Add(project);
}
else if (File.Exists(csProjFilePath))
{
var project = new ProjectDependency(projectDirectory.Name, csProjFilePath);
projects.Add(project);
}
}
internal static List<string> GetGlobalPaths(string rootPath)

View file

@ -55,8 +55,5 @@
public const string RunSettingsArgsHelpText = @"Any extra commandline runsettings arguments that should be passed to vstest. See 'dotnet vstest --help' for available options.
Example: -- RunConfiguration.ResultsDirectory=""C:\users\user\desktop\Results Directory"" MSTest.DeploymentEnabled=false";
public const string CmdResultsDirectoryDescription = @"The test results directory will be created in the specified path if it does not exist.
Example: --results-directory <PATH_TO_RESULTS_DIRECTORY>";
}
}

View file

@ -83,11 +83,6 @@ namespace Microsoft.DotNet.Tools.Test
LocalizableStrings.CmdNoBuildDescription,
CommandOptionType.NoValue);
var resultsDirectoryOption = cmd.Option(
"-r|--results-directory",
LocalizableStrings.CmdResultsDirectoryDescription,
CommandOptionType.SingleValue);
CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(cmd);
cmd.OnExecute(() =>
@ -134,11 +129,6 @@ namespace Microsoft.DotNet.Tools.Test
msbuildArgs.Add($"/p:TargetFramework={frameworkOption.Value()}");
}
if (resultsDirectoryOption.HasValue())
{
msbuildArgs.Add($"/p:VSTestResultsDirectory={resultsDirectoryOption.Value()}");
}
if (outputOption.HasValue())
{
msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}");

View file

@ -302,6 +302,27 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
item => item.ItemType == "ProjectReference" && item.Include == projectReferenceInclude);
}
[Fact]
public void ItDoesNotReferenceTheProjectUnderBackupWhenMigratingAPartiallyMigratedStructure()
{
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
var solutionDirectory = testAssetsManager.CreateTestInstance("PJHalfMigrated").Path;
var appDirectory = Path.Combine(solutionDirectory, "ProjectB");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
mockProj.AddPropertyGroup());
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
var projectReferences = mockProj.Items.Where(
item => item.ItemType.Equals("ProjectReference", StringComparison.Ordinal));
projectReferences.Should().ContainSingle();
projectReferences.Single().Include.Should().Be(Path.Combine("..", "src", "ProjectA", "ProjectA.csproj"));
}
private ProjectRootElement MigrateProject(string solution, string project)
{
return MigrateProject(solution, project, FrameworkConstants.CommonFrameworks.NetCoreApp10);