diff --git a/TestAssets/TestProjects/ProjectJsonWebTemplate/project.json.template b/TestAssets/TestProjects/ProjectJsonWebTemplate/project.json similarity index 100% rename from TestAssets/TestProjects/ProjectJsonWebTemplate/project.json.template rename to TestAssets/TestProjects/ProjectJsonWebTemplate/project.json diff --git a/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/.noautobuild b/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/.noautobuild new file mode 100644 index 000000000..e69de29bb diff --git a/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/Program.cs b/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/Program.cs new file mode 100644 index 000000000..f42d679bf --- /dev/null +++ b/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/Program.cs @@ -0,0 +1,13 @@ +using System; +using System.Xml; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main() + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/project.json b/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/project.json new file mode 100644 index 000000000..33104dede --- /dev/null +++ b/TestAssets/TestProjects/TestLibraryWithTwoFrameworks/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": false + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "imports": "dnxcore50", + "dependencies": { + "NETStandard.Library": "1.6.0" + } + }, + "netstandard1.5": { + "imports": "dnxcore50", + "dependencies": { + "NETStandard.Library": "1.6.0" + } + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index ea33b3a2d..b6496d19e 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -11,14 +11,14 @@ using Microsoft.DotNet.Tools.Migrate; using Build3Command = Microsoft.DotNet.Tools.Test.Utilities.Build3Command; using BuildCommand = Microsoft.DotNet.Tools.Test.Utilities.BuildCommand; using System.Runtime.Loader; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Microsoft.DotNet.Migration.Tests { public class GivenThatIWantToMigrateTestApps : TestBase { [Theory] - // TODO: Standalone apps [InlineData("TestAppSimple", false)] - // https://github.com/dotnet/sdk/issues/73 [InlineData("TestAppWithLibrary/TestApp", false)] [InlineData("TestAppWithRuntimeOptions")] [InlineData("TestAppWithContents")] public void It_migrates_apps(string projectName) @@ -91,14 +91,23 @@ namespace Microsoft.DotNet.Migration.Tests VerifyAllMSBuildOutputsRunnable(projectDirectory); } - [Fact(Skip="https://github.com/dotnet/cli/issues/4299")] - public void It_migrates_dotnet_new_web_with_outputs_containing_project_json_outputs() + [Fact] + public void It_migrates_old_dotnet_new_web_without_tools_with_outputs_containing_project_json_outputs() { var testInstance = TestAssetsManager - .CreateTestInstance("ProjectJsonWebTemplate"); + .CreateTestInstance("ProjectJsonWebTemplate") + .WithLockFiles(); var projectDirectory = testInstance.Path; + var globalDirectory = Path.Combine(projectDirectory, ".."); + var projectJsonFile = Path.Combine(projectDirectory, "project.json"); + + WriteGlobalJson(globalDirectory); + var projectJson = JObject.Parse(File.ReadAllText(projectJsonFile)); + projectJson.Remove("tools"); + File.WriteAllText(projectJsonFile, projectJson.ToString()); + var outputComparisonData = GetComparisonData(projectDirectory); var outputsIdentical = @@ -113,8 +122,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Theory] - // TODO: Enable this when X-Targeting is in - // [InlineData("TestLibraryWithMultipleFrameworks")] + [InlineData("TestLibraryWithTwoFrameworks")] public void It_migrates_projects_with_multiple_TFMs(string projectName) { var projectDirectory = @@ -521,12 +529,12 @@ namespace Microsoft.DotNet.Migration.Tests if (projectName != null) { - command.Execute($"{projectName}.csproj /p:SkipInvalidConfigurations=true") + command.Execute($"{projectName}.csproj /p:SkipInvalidConfigurations=true;_InvalidConfigurationWarning=false") .Should().Pass(); } else { - command.Execute("/p:SkipInvalidConfigurations=true") + command.Execute("/p:SkipInvalidConfigurations=true;_InvalidConfigurationWarning=false") .Should().Pass(); } } @@ -592,5 +600,14 @@ namespace Microsoft.DotNet.Migration.Tests MSBuildBuildOutputs = msBuildBuildOutputs; } } + + private void WriteGlobalJson(string globalDirectory) + { + var file = Path.Combine(globalDirectory, "global.json"); + File.WriteAllText(file, @" + { + ""projects"": [ ] + }"); + } } }