Merge branch 'rel/1.0.0' into test3formultipletfm
This commit is contained in:
commit
679ea57acf
28 changed files with 390 additions and 194 deletions
|
@ -1,6 +1,7 @@
|
|||
// 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;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
|
@ -15,6 +16,16 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
{
|
||||
private static readonly NuGetFramework s_desktopTestFramework = FrameworkConstants.CommonFrameworks.Net451;
|
||||
|
||||
private RepoDirectoriesProvider _repoDirectoriesProvider;
|
||||
|
||||
public GivenAProjectDependenciesCommandFactory()
|
||||
{
|
||||
_repoDirectoriesProvider = new RepoDirectoriesProvider();
|
||||
Environment.SetEnvironmentVariable(
|
||||
Constants.MSBUILD_EXE_PATH,
|
||||
Path.Combine(_repoDirectoriesProvider.Stage2Sdk, "MSBuild.dll"));
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void It_resolves_desktop_apps_defaulting_to_Debug_Configuration()
|
||||
{
|
||||
|
@ -46,6 +57,40 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void It_resolves_desktop_apps_with_MSBuild_defaulting_to_Debug_Configuration()
|
||||
{
|
||||
var configuration = "Debug";
|
||||
|
||||
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
|
||||
var testInstance = testAssetManager.CreateTestInstance("MSBuildAppWithMultipleFrameworksAndTools", "i")
|
||||
.WithLockFiles();
|
||||
|
||||
var projectFile = Path.Combine(testInstance.TestRoot, "MSBuildAppWithMultipleFrameworksAndTools.csproj");
|
||||
|
||||
new Restore3Command()
|
||||
.ExecuteWithCapturedOutput($"{projectFile} -s {_repoDirectoriesProvider.TestPackages}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
new Build3Command()
|
||||
.Execute($"{projectFile} --configuration {configuration}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
var factory = new ProjectDependenciesCommandFactory(
|
||||
s_desktopTestFramework,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
testInstance.TestRoot);
|
||||
|
||||
var command = factory.Create("dotnet-desktop-and-portable", null);
|
||||
|
||||
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
|
||||
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void It_resolves_desktop_apps_when_configuration_is_Debug()
|
||||
{
|
||||
|
|
|
@ -260,6 +260,40 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Migrating_same_file_with_multiple_mappings_string_joins_the_mappings_in_PackagePath()
|
||||
{
|
||||
var mockProj = RunPackOptionsRuleOnPj(@"
|
||||
{
|
||||
""packOptions"": {
|
||||
""files"": {
|
||||
""include"": [""path/to/some/file.cs""],
|
||||
""mappings"": {
|
||||
""other/path/file.cs"": ""path/to/some/file.cs"",
|
||||
""different/path/file1.cs"": ""path/to/some/file.cs""
|
||||
}
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
||||
var expectedPackagePath = string.Join(
|
||||
";",
|
||||
new [] {
|
||||
Path.Combine("different", "path"),
|
||||
Path.Combine("other", "path")
|
||||
});
|
||||
|
||||
var contentItems = mockProj.Items
|
||||
.Where(item => item.ItemType.Equals("Content", StringComparison.Ordinal))
|
||||
.Where(item =>
|
||||
item.GetMetadataWithName("Pack").Value == "true" &&
|
||||
item.GetMetadataWithName("PackagePath") != null);
|
||||
|
||||
contentItems.Count().Should().Be(1);
|
||||
contentItems.First().Include.Should().Be(@"path\to\some\file.cs");
|
||||
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(expectedPackagePath);
|
||||
}
|
||||
|
||||
private ProjectRootElement RunPackOptionsRuleOnPj(string packOptions, string testDirectory = null)
|
||||
{
|
||||
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue