a07ebe2e7b
Conflicts: TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/EmptyItemGroup/EmptyItemGroup.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Lib/Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/MoreThanOne/a.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/MoreThanOne/b.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Net452AndNetCoreApp10Lib/Net452AndNetCoreApp10Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Net45Lib/Net45Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/ValidRef/ValidRef.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithDoubledRef/WithDoubledRef.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithExistingRefCondOnItem/WithExistingRefCondOnItem.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithExistingRefCondWhitespaces/WithExistingRefCondWhitespaces.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithRefCondNonUniform/WithRefCondNonUniform.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithRefNoCondNonUniform/WithRefNoCondNonUniform.csproj TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj build_projects/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.csproj build_projects/dotnet-cli-build/dotnet-cli-build.csproj build_projects/shared-build-targets-utils/shared-build-targets-utils.csproj test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs
107 lines
6.4 KiB
C#
107 lines
6.4 KiB
C#
// 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 Microsoft.DotNet.Tools.Test.Utilities;
|
|
using System.Linq;
|
|
using Xunit;
|
|
using FluentAssertions;
|
|
using System;
|
|
|
|
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|
{
|
|
public class GivenThatIWantToMigrateTools : PackageDependenciesTestBase
|
|
{
|
|
[Theory]
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools", "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-preview2-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-*", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.1", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.0.0-preview3-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGenerators.Mvc", "1.1.0-preview4-final", "Microsoft.VisualStudio.Web.CodeGeneration.Design", ConstantPackageVersions.AspNet110ToolsVersion)]
|
|
[InlineData("Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Design", "1.1.0-preview4-final", "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation", ConstantPackageVersions.AspNet110ToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.0-preview2-final", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.0-*", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.0.1", "Microsoft.VisualStudio.Web.BrowserLink", "1.0.1")]
|
|
[InlineData("Microsoft.VisualStudio.Web.BrowserLink.Loader", "14.1.0-preview4-final", "Microsoft.VisualStudio.Web.BrowserLink", "1.1.0")]
|
|
public void ItMigratesProjectDependenciesToANewNameAndVersion(
|
|
string sourceToolName,
|
|
string sourceVersion,
|
|
string targetToolName,
|
|
string targetVersion)
|
|
{
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"dependencies\": { \"" + sourceToolName + "\" : { \"version\": \"" + sourceVersion + "\", \"type\": \"build\" } } }");
|
|
|
|
var packageRef = mockProj.Items.First(i => i.Include == targetToolName && i.ItemType == "PackageReference");
|
|
|
|
packageRef.GetMetadataWithName("Version").Value.Should().Be(targetVersion);
|
|
|
|
packageRef.GetMetadataWithName("PrivateAssets").Value.Should().NotBeNull().And.Be("All");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Microsoft.AspNetCore.Razor.Tools")]
|
|
[InlineData("Microsoft.AspNetCore.Razor.Design")]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGeneration.Tools")]
|
|
[InlineData("dotnet-test-xunit")]
|
|
[InlineData("dotnet-test-mstest")]
|
|
public void ItDoesNotMigrateProjectToolDependencyThatIsNoLongerNeeded(string dependencyName)
|
|
{
|
|
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
|
{
|
|
""dependencies"": {
|
|
""" + dependencyName + @""" : {
|
|
""version"": ""1.0.0-preview2-final"",
|
|
""type"": ""build""
|
|
}
|
|
}
|
|
}");
|
|
|
|
var packageRef = mockProj.Items.Where(i =>
|
|
i.Include != "Microsoft.NET.Sdk" &&
|
|
i.Include != "NETStandard.Library" &&
|
|
i.ItemType == "PackageReference").Should().BeEmpty();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools.DotNet", "Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.EntityFrameworkCore.Tools", "Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.VisualStudio.Web.CodeGeneration.Tools", "Microsoft.VisualStudio.Web.CodeGeneration.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.DotNet.Watcher.Tools", "Microsoft.DotNet.Watcher.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("Microsoft.Extensions.SecretManager.Tools", "Microsoft.Extensions.SecretManager.Tools", ConstantPackageVersions.AspNetToolsVersion)]
|
|
[InlineData("BundlerMinifier.Core", "BundlerMinifier.Core", ConstantPackageVersions.BundleMinifierToolVersion)]
|
|
public void ItMigratesAspProjectToolsToANewNameAndVersion(
|
|
string sourceToolName,
|
|
string targetToolName,
|
|
string targetVersion)
|
|
{
|
|
const string anyVersion = "1.0.0-preview2-final";
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"tools\": { \"" + sourceToolName + "\": \"" + anyVersion + "\" } }");
|
|
|
|
EmitsToolReferences(mockProj, Tuple.Create(targetToolName, targetVersion));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("Microsoft.AspNetCore.Razor.Tools")]
|
|
[InlineData("Microsoft.AspNetCore.Server.IISIntegration.Tools")]
|
|
[InlineData("Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tools")]
|
|
public void ItDoesNotMigrateAspProjectTool(string toolName)
|
|
{
|
|
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
|
{
|
|
""tools"": {
|
|
""" + toolName + @""": ""1.0.0-preview2-final""
|
|
}
|
|
}");
|
|
|
|
var packageRef = mockProj.Items.Where(i => i.ItemType == "DotNetCliToolReference").Should().BeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void ItMergesEntityFrameworkCoreToolsAndEntityFrameworkCoreToolsDotNet()
|
|
{
|
|
var mockProj = RunPackageDependenciesRuleOnPj("{ \"tools\": { \"Microsoft.EntityFrameworkCore.Tools\": \"1.0.0-preview4-final\", \"Microsoft.EntityFrameworkCore.Tools.DotNet\": \"1.0.0-preview4-final\" } }");
|
|
|
|
EmitsToolReferences(mockProj, Tuple.Create("Microsoft.EntityFrameworkCore.Tools.DotNet", ConstantPackageVersions.AspNetToolsVersion));
|
|
}
|
|
}
|
|
}
|