diff --git a/TestAssets/TestProjects/TestAppWithMultipleFrameworksAndNoRuntimes/project.json b/TestAssets/TestProjects/TestAppWithMultipleFrameworksAndNoRuntimes/project.json index f2f365fdc..d9a0a12b4 100644 --- a/TestAssets/TestProjects/TestAppWithMultipleFrameworksAndNoRuntimes/project.json +++ b/TestAssets/TestProjects/TestAppWithMultipleFrameworksAndNoRuntimes/project.json @@ -5,21 +5,6 @@ }, "dependencies": {}, "frameworks": { - "net20": { - "frameworkAssemblies": { - "System.Xml": {} - } - }, - "net35": { - "frameworkAssemblies": { - "System.Xml": {} - } - }, - "net40": { - "frameworkAssemblies": { - "System.Xml": {} - } - }, "net461": { "frameworkAssemblies": { "System.Xml": {} @@ -27,7 +12,10 @@ }, "netcoreapp1.0": { "dependencies": { - "Microsoft.NetCore.App": "1.0.1" + "Microsoft.NetCore.App": { + "version": "1.0.1", + "type": "platform" + } } } } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs index c8d99e068..20e11005a 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateTFMRule.cs @@ -149,9 +149,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules " OR ", projectContexts.Where(p => p.IsFullFramework()).Select( p => $"'$(TargetFramework)' == '{p.TargetFramework.GetShortFolderName()}'")); + + msBuildCondition = $" {msBuildCondition} "; } - return $" {msBuildCondition} "; + return msBuildCondition; }); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs index ece044d55..48b411471 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities private string _configuration; - private NuGetFramework _framework; + private string _framework; private string _runtime; @@ -72,6 +72,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities } public BuildCommand WithFramework(NuGetFramework framework) + { + _framework = framework.GetShortFolderName(); + + return this; + } + + public BuildCommand WithFramework(string framework) { _framework = framework; @@ -137,7 +144,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return null; } - return $"--framework {_framework.GetShortFolderName()}"; + return $"--framework {_framework}"; } private string GetRuntime() diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index a3e2b8b18..87936e44c 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -27,26 +27,6 @@ namespace Microsoft.DotNet.Migration.Tests [InlineData("AppWithAssemblyInfo")] [InlineData("TestAppWithEmbeddedResources")] public void ItMigratesApps(string projectName) - { - var projectDirectory = MigrateApps(projectName); - - VerifyAllMSBuildOutputsRunnable(projectDirectory); - - var outputCsProj = Path.Combine(projectDirectory, projectName + ".csproj"); - var csproj = File.ReadAllText(outputCsProj); - csproj.EndsWith("\n").Should().Be(true); - } - - [WindowsOnlyTheory] - [InlineData("TestAppWithMultipleFrameworksAndRuntimes")] - [InlineData("TestAppWithMultipleFrameworksAndNoRuntimes")] - [InlineData("TestAppWithMultipleFrameworksOnly")] - public void ItMigratesAppsWithFullFramework(string projectName) - { - MigrateApps(projectName); - } - - private string MigrateApps(string projectName) { var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName) .WithLockFiles() @@ -66,7 +46,29 @@ namespace Microsoft.DotNet.Migration.Tests outputsIdentical.Should().BeTrue(); - return projectDirectory; + VerifyAllMSBuildOutputsRunnable(projectDirectory); + + var outputCsProj = Path.Combine(projectDirectory, projectName + ".csproj"); + var csproj = File.ReadAllText(outputCsProj); + csproj.EndsWith("\n").Should().Be(true); + } + + [WindowsOnlyTheory] + [InlineData("TestAppWithMultipleFrameworksAndNoRuntimes", null)] + [InlineData("TestAppWithMultipleFullFrameworksOnly", "net461")] + public void ItMigratesAppsWithFullFramework(string projectName, string framework) + { + var projectDirectory = TestAssetsManager.CreateTestInstance( + projectName, + identifier: projectName).WithLockFiles().Path; + + CleanBinObj(projectDirectory); + + MigrateProject(new [] { projectDirectory }); + + Restore(projectDirectory); + + BuildMSBuild(projectDirectory, projectName, framework: framework); } [Fact] @@ -711,7 +713,8 @@ namespace Microsoft.DotNet.Migration.Tests string projectDirectory, string projectName, string configuration="Debug", - string runtime=null) + string runtime=null, + string framework=null) { if (projectName != null && !Path.HasExtension(projectName)) { @@ -723,6 +726,7 @@ namespace Microsoft.DotNet.Migration.Tests var result = new BuildCommand() .WithWorkingDirectory(projectDirectory) .WithRuntime(runtime) + .WithFramework(framework) .ExecuteWithCapturedOutput($"{projectName} /p:Configuration={configuration}"); result