Merge pull request #4494 from livarcocc/migrate_target_package

When determining the P2P dependencies, only use dependencies of type project
This commit is contained in:
Livar 2016-10-25 22:25:28 -07:00 committed by GitHub
commit 8befd890d8
8 changed files with 113 additions and 2 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,29 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": "1.0.1",
"TestLibraryAsAPackage": {
"version": "1.0.0",
"target": "package"
}
},
"frameworks": {
"netcoreapp1.0": {}
},
"runtimes": {
"win7-x64": {},
"win7-x86": {},
"osx.10.10-x64": {},
"osx.10.11-x64": {},
"ubuntu.14.04-x64": {},
"ubuntu.16.04-x64": {},
"centos.7-x64": {},
"rhel.7.2-x64": {},
"debian.8-x64": {},
"fedora.23-x64": {},
"opensuse.13.2-x64": {}
}
}

View file

@ -0,0 +1,24 @@
// 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 System;
namespace TestLibrary
{
public static class Helper
{
/// <summary>
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
/// </summary>
/// <returns>A message</returns>
public static string GetMessage()
{
return "This string came from the test library!";
}
public static void SayHi()
{
Console.WriteLine("Hello there!");
}
}
}

View file

@ -0,0 +1,18 @@
{
"version": "1.0.0-*",
"buildOptions": {
"nowarn": [
"CS1591"
],
"xmlDoc": true,
"additionalArguments": [
"-highentropyva+"
]
},
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.5": {}
}
}

View file

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

View file

@ -66,7 +66,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration
projectFileDependenciesForFramework = project.GetTargetFramework(framework).Dependencies;
}
foreach (var projectFileDependency in projectFileDependenciesForFramework)
foreach (var projectFileDependency in
projectFileDependenciesForFramework.Where(p =>
p.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project))
{
var dependencyName = projectFileDependency.Name;
@ -105,7 +107,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
FindPossibleProjectDependencies(projectContext.ProjectFile.ProjectFilePath);
var projectDependencies = new List<ProjectDependency>();
foreach (var projectExport in projectExports)
foreach (var projectExport in
projectExports.Where(p => p.Library.Identity.Type == LibraryType.Project))
{
var projectExportName = projectExport.Library.Identity.Name;
ProjectDependency projectDependency;

View file

@ -1,6 +1,7 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using System;
@ -39,6 +40,27 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
projectReference.Parent.Condition.Should().BeEmpty();
}
[Fact]
public void It_does_not_migrate_a_dependency_with_target_package_that_has_a_matching_project_as_a_ProjectReference()
{
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
var solutionDirectory =
testAssetsManager.CreateTestInstance("AppWithProjectDependencyAsTarget", callingMethod: "p").Path;
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", 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().BeEmpty();
}
[Fact]
public void TFM_specific_Project_dependencies_are_migrated_to_ProjectReference_under_condition_ItemGroup()
{