From e17c44edddbbee129c69739b351db97f810ee27d Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Wed, 25 Jan 2017 09:53:59 -0800 Subject: [PATCH 01/10] WIP --- .../ProjectReader.cs | 263 +++++++++++++++--- .../ProjectMigrator.cs | 9 +- 2 files changed, 234 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 57583883e..50802ac70 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -809,50 +809,243 @@ namespace Microsoft.DotNet.Internal.ProjectModel private static void AddProjectFilesCollectionDiagnostics(JObject rawProject, Project project) { - var compileWarning = "'compile' in 'buildOptions'"; - AddDiagnosticMesage(rawProject, project, "compile", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileExclude", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileFiles", compileWarning); - AddDiagnosticMesage(rawProject, project, "compileBuiltIn", compileWarning); + ConvertDeprecatedCompileOptions(rawProject, project); + ConvertDeprecatedContentOptions(rawProject, project); + ConvertDeprecatedResourceOptions(rawProject, project); - var resourceWarning = "'embed' in 'buildOptions'"; - AddDiagnosticMesage(rawProject, project, "resource", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceExclude", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceFiles", resourceWarning); - AddDiagnosticMesage(rawProject, project, "resourceBuiltIn", resourceWarning); - AddDiagnosticMesage(rawProject, project, "namedResource", resourceWarning); + ConvertFromDeprecatedFormat( + rawProject, + project, + "'files' in 'packOptions'", + "packInclude", + new string[] { "packOptions" }, + "files"); - var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; - AddDiagnosticMesage(rawProject, project, "content", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentExclude", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentFiles", contentWarning); - AddDiagnosticMesage(rawProject, project, "contentBuiltIn", contentWarning); - - AddDiagnosticMesage(rawProject, project, "packInclude", "'files' in 'packOptions'"); - AddDiagnosticMesage(rawProject, project, "publishExclude", "'publishOptions'"); - AddDiagnosticMesage(rawProject, project, "exclude", "'exclude' within 'compile' or 'embed'"); + ConvertFromDeprecatedFormat( + rawProject, + project, + "'publishOptions'", + "publishExclude", + new string[] { "publishOptions" }, + "excludeFiles"); } - private static void AddDiagnosticMesage( + private static void ConvertDeprecatedCompileOptions(JObject rawProject, Project project) + { + var compileWarning = "'compile' in 'buildOptions'"; + var compileObjectHierarchy = new string[] { "buildOptions", "compile" }; + + ConvertFromDeprecatedFormat( + rawProject, + project, + compileWarning, + "compile", + compileObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + compileWarning, + "compileExclude", + compileObjectHierarchy, + "excludeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + compileWarning, + "compileFiles", + compileObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + compileWarning, + "compileBuiltIn", + compileObjectHierarchy, + "builtIns"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + compileWarning, + "exclude", + compileObjectHierarchy, + "exclude"); + } + + private static void ConvertDeprecatedContentOptions(JObject rawProject, Project project) + { + var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; + var copyToOutputObjectHierarchy = new string[] { "buildOptions", "copyToOutput" }; + var publishObjectHierarchy = new string[] { "publishOptions" }; + + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "content", + copyToOutputObjectHierarchy, + "includeFiles"); + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "content", + publishObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentExclude", + copyToOutputObjectHierarchy, + "excludeFiles"); + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentExclude", + publishObjectHierarchy, + "excludeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentFiles", + copyToOutputObjectHierarchy, + "includeFiles"); + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentFiles", + publishObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentFiles", + copyToOutputObjectHierarchy, + "contentBuiltIn"); + ConvertFromDeprecatedFormat( + rawProject, + project, + contentWarning, + "contentBuiltIn", + publishObjectHierarchy, + "builtIns"); + } + + private static void ConvertDeprecatedResourceOptions(JObject rawProject, Project project) + { + var resourceWarning = "'embed' in 'buildOptions'"; + var embedObjectHierarchy = new string[] { "buildOptions", "embed" }; + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "resource", + embedObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "resourceExclude", + embedObjectHierarchy, + "excludeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "resourceFiles", + embedObjectHierarchy, + "includeFiles"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "resourceBuiltIn", + embedObjectHierarchy, + "builtIns"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "namedResource", + embedObjectHierarchy, + "mappings"); + + ConvertFromDeprecatedFormat( + rawProject, + project, + resourceWarning, + "exclude", + embedObjectHierarchy, + "exclude"); + } + + private static void ConvertFromDeprecatedFormat( JObject rawProject, Project project, - string option, - string message) + string message, + string deprecatedKey, + string[] newKeyObjectHierarchy, + string newKey + ) { - var lineInfo = rawProject.Value(option); - if (lineInfo == null) + var deprecatedValue = rawProject.Value(deprecatedKey); + if (deprecatedValue != null) { - return; - } + var currentObject = rawProject; + foreach (var key in newKeyObjectHierarchy) + { + var childObject = currentObject.Value(key) as JObject; + if (childObject == null) + { + childObject = new JObject(); + currentObject[key] = childObject; + } - project.Diagnostics.Add( - new DiagnosticMessage( - ErrorCodes.DOTNET1015, - $"The '{option}' option is deprecated. Use {message} instead.", - project.ProjectFilePath, - DiagnosticMessageSeverity.Warning, - lineInfo.LineNumber, - lineInfo.LinePosition)); + currentObject = childObject; + } + + if (deprecatedValue is JObject) + { + currentObject[newKey] = (deprecatedValue as JObject).DeepClone(); + //(currentObject[newKey] as JObject).Merge((deprecatedValue as JObject).DeepClone(), new JsonMergeSettings + //{ + // // union array values together to avoid duplicates + // MergeArrayHandling = MergeArrayHandling.Union + //}); + } + else if (deprecatedValue is JToken) + { + currentObject[newKey] = (deprecatedValue as JToken).DeepClone(); + //JToken.FromObject(x.Concat(x)) + } + + project.Diagnostics.Add( + new DiagnosticMessage( + ErrorCodes.DOTNET1015, + $"The '{deprecatedKey}' option is deprecated. Use {message} instead.", + project.ProjectFilePath, + DiagnosticMessageSeverity.Warning, + deprecatedValue.LineNumber, + deprecatedValue.LinePosition)); + } } private static bool TryGetStringEnumerable(JToken token, out IEnumerable result) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 2596d8f2f..7b2a31446 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -9,6 +9,7 @@ using Microsoft.Build.Construction; using Microsoft.DotNet.Internal.ProjectModel; using Microsoft.DotNet.Internal.ProjectModel.Graph; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils.ExceptionExtensions; using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.ProjectJsonMigration.Rules; @@ -251,9 +252,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration var diagnostics = defaultProjectContext.ProjectFile.Diagnostics; if (diagnostics.Any()) { - MigrationErrorCodes.MIGRATE1011( - String.Format("{0}{1}{2}", projectDirectory, Environment.NewLine, string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))) - .Throw(); + var deprecatedProjectJsonWarnings = string.Join( + Environment.NewLine, + diagnostics.Select(d => FormatDiagnosticMessage(d))); + var warnings = $"{projectDirectory}{Environment.NewLine}{deprecatedProjectJsonWarnings}"; + Reporter.Output.WriteLine(warnings.Yellow()); } var compilerName = From b8d4010d85d44ce4306e731a8aaccae70fc04853 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Wed, 25 Jan 2017 12:30:56 -0800 Subject: [PATCH 02/10] Handle some of the deprecated properties --- .../Program.cs | 12 ++ .../project.json | 20 +++ .../PJAppWithDeprecatedPackOptions/Program.cs | 12 ++ .../project.json | 31 ++++ .../.noautobuild | 0 .../Helper.cs | 15 -- .../project.json | 13 -- .../GivenAProjectMigrator.cs | 21 --- ...venThatIWantToMigrateDeprecatedProjects.cs | 164 ++++++++++++++++++ 9 files changed, 239 insertions(+), 49 deletions(-) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json delete mode 100644 TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/.noautobuild delete mode 100644 TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs delete mode 100644 TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json create mode 100644 test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/project.json new file mode 100644 index 000000000..9f677856d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompilationOptions/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "compilerName": "csc", + "compilationOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json new file mode 100644 index 000000000..5ebe3586d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0-*", + "projectUrl": "http://projecturl/", + "licenseUrl": "http://licenseurl/", + "iconUrl": "http://iconurl/", + "owners": [ "owner1", "owner2" ], + "tags": [ "tag1", "tag2" ], + "releaseNotes": "releaseNotes", + "requireLicenseAcceptance": true, + "summary": "summary", + "repository": { + "type": "git", + "url": "http://url/" + }, + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/.noautobuild b/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/.noautobuild deleted file mode 100644 index e69de29bb..000000000 diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs b/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs deleted file mode 100644 index bd9a33ffe..000000000 --- a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/Helper.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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 - { - public static void SayHi() - { - Console.WriteLine("Hello there!"); - } - } -} diff --git a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json b/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json deleted file mode 100644 index 90cf856ff..000000000 --- a/TestAssets/TestProjects/TestLibraryWithDeprecatedProjectFile/project.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "xmlDoc": true - }, - "packInclude": {}, - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "frameworks": { - "netstandard1.5": {} - } -} diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs index d15de0265..d1cb75935 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs @@ -38,27 +38,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } } - [Fact] - public void ItHasErrorWhenMigratingADeprecatedProjectJson() - { - var testProjectDirectory = - TestAssetsManager.CreateTestInstance("TestLibraryWithDeprecatedProjectFile", callingMethod: "z") - .Path; - - var mockProj = ProjectRootElement.Create(); - var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, testProjectDirectory, mockProj); - - var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); - var report = projectMigrator.Migrate(testSettings); - - var projectReport = report.ProjectMigrationReports.First(); - - var errorMessage = projectReport.Errors.First().GetFormattedErrorMessage(); - errorMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); - errorMessage.Should().Contain("The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead. (line: 6, file:"); - errorMessage.Should().Contain("The 'compilationOptions' option is deprecated. Use 'buildOptions' instead. (line: 3, file:"); - } - [Fact] public void ItHasErrorWhenMigratingANonCsharpApp() { diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs new file mode 100644 index 000000000..5d91b0e8b --- /dev/null +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -0,0 +1,164 @@ +// 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 FluentAssertions; +using Microsoft.DotNet.TestFramework; +using Microsoft.DotNet.Tools.Test.Utilities; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Xml.Linq; +using Xunit; + +namespace Microsoft.DotNet.Migration.Tests +{ + public class GivenThatIWantToMigrateDeprecatedProjects : TestBase + { + [Fact] + public void WhenMigratingAProjectWithDeprecatedPackOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedPackOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'repository' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'projectUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'licenseUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'iconUrl' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'owners' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'tags' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'releaseNotes' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'requireLicenseAcceptance' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'summary' option in the root is deprecated. Use it in 'packOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedPackOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedPackOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("pack") + .Should().Pass(); + + var outputDir = projectDirectory.GetDirectory("bin", "Debug"); + outputDir.Should().Exist() + .And.HaveFile("PJAppWithDeprecatedPackOptions.1.0.0.nupkg"); + + var outputPackage = outputDir.GetFile("PJAppWithDeprecatedPackOptions.1.0.0.nupkg"); + + var zip = ZipFile.Open(outputPackage.FullName, ZipArchiveMode.Read); + zip.Entries.Should().Contain(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec"); + + var manifestReader = new StreamReader( + zip.Entries.First(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec").Open()); + + // NOTE: Commented out those that are not migrated. + // https://microsoft.sharepoint.com/teams/netfx/corefx/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0cfbc196-0645-4781-84c6-5dffabd76bee%7D&action=edit&wd=target%28Planning%2FMSBuild%20CLI%20integration%2Eone%7C41D470DD-CF44-4595-8E05-0CE238864B55%2FProject%2Ejson%20Migration%7CA553D979-EBC6-484B-A12E-036E0730864A%2F%29 + var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd()); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "projectUrl").Value + .Should().Be("http://projecturl/"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "licenseUrl").Value + .Should().Be("http://licenseurl/"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "iconUrl").Value + .Should().Be("http://iconurl/"); + //nuspecXml.Descendants().Single(e => e.Name.LocalName == "owners").Value + // .Should().Be("owner1,owner2"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "tags").Value + .Should().Be("tag1 tag2"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "releaseNotes").Value + .Should().Be("releaseNotes"); + nuspecXml.Descendants().Single(e => e.Name.LocalName == "requireLicenseAcceptance").Value + .Should().Be("true"); + //nuspecXml.Descendants().Single(e => e.Name.LocalName == "summary").Value + // .Should().Be("summary"); + + var repositoryNode = nuspecXml.Descendants().Single(e => e.Name.LocalName == "repository"); + repositoryNode.Attributes("type").Single().Value.Should().Be("git"); + repositoryNode.Attributes("url").Single().Value.Should().Be("http://url/"); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompilationOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompilationOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compilerName' option in the root is deprecated. Use it in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'compilationOptions' option is deprecated. Use 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompilationOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompilationOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + } + } +} From 150e3c431313725101a3906f163f2318d6aa9a5e Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Wed, 25 Jan 2017 17:28:57 -0800 Subject: [PATCH 03/10] Add more tests --- .../ContentFile1.txt | 1 + .../ContentFile2.txt | 1 + .../ContentFileBuiltIn1.txt | 1 + .../ContentFileBuiltIn2.txt | 1 + .../project/ExcludeThis.txt | 1 + .../project/IncludeThis1.txt | 1 + .../project/IncludeThis2.txt | 1 + .../project/Program.cs | 12 + .../project/project.json | 24 ++ .../Content1.txt | 1 + .../Content2.txt | 1 + .../project.json | 1 + .../ProjectReader.cs | 386 ++++++++---------- ...venThatIWantToMigrateDeprecatedProjects.cs | 88 +++- 14 files changed, 293 insertions(+), 227 deletions(-) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile1.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile2.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn1.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn2.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content1.txt create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content2.txt diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile1.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile1.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile1.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile2.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFile2.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn1.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn1.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn1.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn2.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/ContentFileBuiltIn2.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt new file mode 100644 index 000000000..949ca7b7c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt @@ -0,0 +1 @@ +Test content file that should be excluded. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt new file mode 100644 index 000000000..49852374c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt @@ -0,0 +1 @@ +Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json new file mode 100644 index 000000000..15c8a8cbe --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json @@ -0,0 +1,24 @@ +{ + "version": "1.0.0-*", + "content": "*.txt", + "contentExclude": "ExcludeThis.txt", + "contentFiles": [ "../ContentFile1.txt", "../ContentFile2.txt" ], + "contentBuiltIn": [ "../ContentFileBuiltIn1.txt", "../ContentFileBuiltIn2.txt" ], + "publishExclude": "IncludeThis2.txt", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content1.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content1.txt new file mode 100644 index 000000000..a36501f3f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content1.txt @@ -0,0 +1 @@ +Test pack content file. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content2.txt new file mode 100644 index 000000000..a36501f3f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/Content2.txt @@ -0,0 +1 @@ +Test pack content file. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json index 5ebe3586d..5daf77a20 100644 --- a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedPackOptions/project.json @@ -12,6 +12,7 @@ "type": "git", "url": "http://url/" }, + "packInclude": [ "Content1.txt", "Content2.txt" ], "buildOptions": { "debugType": "portable", "emitEntryPoint": true diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 50802ac70..2c6e07710 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -165,7 +165,8 @@ namespace Microsoft.DotNet.Internal.ProjectModel // Project files project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath); - AddProjectFilesCollectionDiagnostics(rawProject, project); + AddProjectFilesDeprecationDiagnostics(rawProject, project); + ConvertDeprecatedToSupportedFormat(rawProject); var commands = rawProject.Value("commands") as JObject; if (commands != null) @@ -758,10 +759,14 @@ namespace Microsoft.DotNet.Internal.ProjectModel if (rawPackOptions != null) { - var packOptionValue = rawPackOptions.Value(option); - if (packOptionValue != null) + var hasOption = rawPackOptions.Value(option) != null; + if (hasOption) { - return packOptionValue; + var packOptionValue = rawPackOptions.Value(option); + if (packOptionValue != null) + { + return packOptionValue; + } } } @@ -807,244 +812,173 @@ namespace Microsoft.DotNet.Internal.ProjectModel return File.Exists(projectPath); } - private static void AddProjectFilesCollectionDiagnostics(JObject rawProject, Project project) - { - ConvertDeprecatedCompileOptions(rawProject, project); - ConvertDeprecatedContentOptions(rawProject, project); - ConvertDeprecatedResourceOptions(rawProject, project); - - ConvertFromDeprecatedFormat( - rawProject, - project, - "'files' in 'packOptions'", - "packInclude", - new string[] { "packOptions" }, - "files"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - "'publishOptions'", - "publishExclude", - new string[] { "publishOptions" }, - "excludeFiles"); - } - - private static void ConvertDeprecatedCompileOptions(JObject rawProject, Project project) + private static void AddProjectFilesDeprecationDiagnostics(JObject rawProject, Project project) { var compileWarning = "'compile' in 'buildOptions'"; - var compileObjectHierarchy = new string[] { "buildOptions", "compile" }; + AddDeprecatedDiagnosticMessage(rawProject, project, "compile", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileExclude", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileFiles", compileWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "compileBuiltIn", compileWarning); - ConvertFromDeprecatedFormat( - rawProject, - project, - compileWarning, - "compile", - compileObjectHierarchy, - "includeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - compileWarning, - "compileExclude", - compileObjectHierarchy, - "excludeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - compileWarning, - "compileFiles", - compileObjectHierarchy, - "includeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - compileWarning, - "compileBuiltIn", - compileObjectHierarchy, - "builtIns"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - compileWarning, - "exclude", - compileObjectHierarchy, - "exclude"); - } - - private static void ConvertDeprecatedContentOptions(JObject rawProject, Project project) - { - var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; - var copyToOutputObjectHierarchy = new string[] { "buildOptions", "copyToOutput" }; - var publishObjectHierarchy = new string[] { "publishOptions" }; - - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "content", - copyToOutputObjectHierarchy, - "includeFiles"); - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "content", - publishObjectHierarchy, - "includeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentExclude", - copyToOutputObjectHierarchy, - "excludeFiles"); - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentExclude", - publishObjectHierarchy, - "excludeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentFiles", - copyToOutputObjectHierarchy, - "includeFiles"); - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentFiles", - publishObjectHierarchy, - "includeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentFiles", - copyToOutputObjectHierarchy, - "contentBuiltIn"); - ConvertFromDeprecatedFormat( - rawProject, - project, - contentWarning, - "contentBuiltIn", - publishObjectHierarchy, - "builtIns"); - } - - private static void ConvertDeprecatedResourceOptions(JObject rawProject, Project project) - { var resourceWarning = "'embed' in 'buildOptions'"; - var embedObjectHierarchy = new string[] { "buildOptions", "embed" }; + AddDeprecatedDiagnosticMessage(rawProject, project, "resource", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceExclude", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceFiles", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "resourceBuiltIn", resourceWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "namedResource", resourceWarning); - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "resource", - embedObjectHierarchy, - "includeFiles"); + var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; + AddDeprecatedDiagnosticMessage(rawProject, project, "content", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentExclude", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentFiles", contentWarning); + AddDeprecatedDiagnosticMessage(rawProject, project, "contentBuiltIn", contentWarning); - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "resourceExclude", - embedObjectHierarchy, - "excludeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "resourceFiles", - embedObjectHierarchy, - "includeFiles"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "resourceBuiltIn", - embedObjectHierarchy, - "builtIns"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "namedResource", - embedObjectHierarchy, - "mappings"); - - ConvertFromDeprecatedFormat( - rawProject, - project, - resourceWarning, - "exclude", - embedObjectHierarchy, - "exclude"); + AddDeprecatedDiagnosticMessage(rawProject, project, "packInclude", "'files' in 'packOptions'"); + AddDeprecatedDiagnosticMessage(rawProject, project, "publishExclude", "'publishOptions'"); + AddDeprecatedDiagnosticMessage(rawProject, project, "exclude", "'exclude' within 'compile' or 'embed'"); } - private static void ConvertFromDeprecatedFormat( + private static void AddDeprecatedDiagnosticMessage( JObject rawProject, Project project, - string message, + string option, + string message) + { + var lineInfo = rawProject.Value(option); + if (lineInfo == null) + { + return; + } + + project.Diagnostics.Add( + new DiagnosticMessage( + ErrorCodes.DOTNET1015, + $"The '{option}' option is deprecated. Use {message} instead.", + project.ProjectFilePath, + DiagnosticMessageSeverity.Warning, + lineInfo.LineNumber, + lineInfo.LinePosition)); + } + + private static void ConvertDeprecatedToSupportedFormat(JObject rawProject) + { + ConvertToBuildOptionsCompile(rawProject); + ConvertToBuildOptionsEmbed(rawProject); + ConvertToBuildOptionsCopyToOutput(rawProject); + ConvertToPackOptions(rawProject); + ConvertToPublishOptions(rawProject); + } + + private static void ConvertToBuildOptionsCompile(JObject rawProject) + { + var jpath = "buildOptions.compile"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "compile", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "exclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "compileExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "compileFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "compileBuiltIn", "include"); + } + + private static void ConvertToBuildOptionsEmbed(JObject rawProject) + { + var jpath = "buildOptions.embed"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "resource", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "exclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "resourceExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "resourceFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "namedResource", "mappings"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "resourceBuiltIn", "include"); + } + + private static void ConvertToBuildOptionsCopyToOutput(JObject rawProject) + { + var jpath = "buildOptions.copyToOutput"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "content", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "contentBuiltIn", "include"); + } + + private static void ConvertToPackOptions(JObject rawProject) + { + var jpath = "packOptions"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.files", "packInclude", "include"); + } + + private static void ConvertToPublishOptions(JObject rawProject) + { + var jpath = "publishOptions"; + if (AreDeprecatedOptionsIgnored(rawProject, jpath)) + { + return; + } + + ConvertFromDeprecatedFormat(rawProject, jpath, "content", "include"); + ConvertFromDeprecatedFormat(rawProject, jpath, "publishExclude", "exclude"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentExclude", "excludeFiles"); + ConvertFromDeprecatedFormat(rawProject, jpath, "contentFiles", "includeFiles"); + ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "contentBuiltIn", "include"); + } + + private static bool AreDeprecatedOptionsIgnored(JObject rawProject, string jpathToNewFormatObject) + { + // If the node already exists this means that the project.json file contained both the old and + // new format. In these cases the project.json build ignores the deprecated format and just uses + // the new format. + return (rawProject.SelectToken(jpathToNewFormatObject) != null); + } + + private static JObject GetOrCreateObjectHierarchy(JObject rawProject, string jpath) + { + var currentObject = rawProject as JObject; + + var objectHierarchy = jpath.Split('.'); + foreach (var name in objectHierarchy) + { + var childObject = currentObject.Value(name); + if (childObject == null) + { + childObject = new JObject(); + currentObject[name] = childObject; + } + currentObject = childObject; + } + + return currentObject; + } + + private static void ConvertFromDeprecatedFormat( + JObject rawProject, + string jpathToObject, string deprecatedKey, - string[] newKeyObjectHierarchy, string newKey ) { - var deprecatedValue = rawProject.Value(deprecatedKey); + var deprecatedValue = rawProject.Value(deprecatedKey); if (deprecatedValue != null) { - var currentObject = rawProject; - foreach (var key in newKeyObjectHierarchy) - { - var childObject = currentObject.Value(key) as JObject; - if (childObject == null) - { - childObject = new JObject(); - currentObject[key] = childObject; - } - - currentObject = childObject; - } - - if (deprecatedValue is JObject) - { - currentObject[newKey] = (deprecatedValue as JObject).DeepClone(); - //(currentObject[newKey] as JObject).Merge((deprecatedValue as JObject).DeepClone(), new JsonMergeSettings - //{ - // // union array values together to avoid duplicates - // MergeArrayHandling = MergeArrayHandling.Union - //}); - } - else if (deprecatedValue is JToken) - { - currentObject[newKey] = (deprecatedValue as JToken).DeepClone(); - //JToken.FromObject(x.Concat(x)) - } - - project.Diagnostics.Add( - new DiagnosticMessage( - ErrorCodes.DOTNET1015, - $"The '{deprecatedKey}' option is deprecated. Use {message} instead.", - project.ProjectFilePath, - DiagnosticMessageSeverity.Warning, - deprecatedValue.LineNumber, - deprecatedValue.LinePosition)); + var objectNode = GetOrCreateObjectHierarchy(rawProject, jpathToObject); + objectNode[newKey] = deprecatedValue.DeepClone(); } } diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index 5d91b0e8b..07d48eb88 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -47,6 +47,8 @@ namespace Microsoft.DotNet.Migration.Tests "The 'requireLicenseAcceptance' option in the root is deprecated. Use it in 'packOptions' instead."); cmd.StdOut.Should().Contain( "The 'summary' option in the root is deprecated. Use it in 'packOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead."); } [Fact] @@ -85,7 +87,9 @@ namespace Microsoft.DotNet.Migration.Tests var outputPackage = outputDir.GetFile("PJAppWithDeprecatedPackOptions.1.0.0.nupkg"); var zip = ZipFile.Open(outputPackage.FullName, ZipArchiveMode.Read); - zip.Entries.Should().Contain(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec"); + zip.Entries.Should().Contain(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec") + .And.Contain(e => e.FullName == "content/Content1.txt") + .And.Contain(e => e.FullName == "content/Content2.txt"); var manifestReader = new StreamReader( zip.Entries.First(e => e.FullName == "PJAppWithDeprecatedPackOptions.nuspec").Open()); @@ -160,5 +164,87 @@ namespace Microsoft.DotNet.Migration.Tests .Execute("build") .Should().Pass(); } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedContentOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedContentOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'content' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentExclude' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentFiles' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + cmd.StdOut.Should().Contain( + "The 'contentBuiltIn' option is deprecated. Use 'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedContentOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedContentOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("publish") + .Should().Pass(); + + var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0"); + outputDir.Should().Exist() + .And.HaveFiles(new[] + { + "ContentFile1.txt", + "ContentFile2.txt", + "ContentFileBuiltIn1.txt", + "ContentFileBuiltIn2.txt", + "IncludeThis1.txt", + }); + Directory.Exists(Path.Combine(outputDir.FullName, "IncludeThis2.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis.txt")).Should().BeFalse(); + + var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish"); + publishDir.Should().Exist() + .And.HaveFiles(new[] + { + "ContentFile1.txt", + "ContentFile2.txt", + "ContentFileBuiltIn1.txt", + "ContentFileBuiltIn2.txt", + "IncludeThis1.txt", + }); + Directory.Exists(Path.Combine(publishDir.FullName, "IncludeThis2.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis.txt")).Should().BeFalse(); + } } } From ddf3261a67c95e5a4d8619ac12c92d4823bbec14 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 08:34:36 -0800 Subject: [PATCH 04/10] Add more tests --- .../HelperBuiltIn1.cs | 12 ++ .../HelperBuiltIn2.cs | 12 ++ .../project/IncludeThis.cs | 12 ++ .../project/Program.cs | 14 ++ .../project/project.json | 20 +++ .../ExcludeThis.cs | 1 + .../Program.cs | 12 ++ .../project.json | 20 +++ .../Helper1.cs | 12 ++ .../Helper2.cs | 12 ++ .../project/IncludeThis.cs | 12 ++ .../project/Program.cs | 14 ++ .../project/project.json | 21 +++ ...venThatIWantToMigrateDeprecatedProjects.cs | 138 ++++++++++++++++++ 14 files changed, 312 insertions(+) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn1.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn2.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/IncludeThis.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper1.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper2.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/IncludeThis.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/project.json diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn1.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn1.cs new file mode 100644 index 000000000..042fc53d1 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class HelperBuiltIn1 + { + public static string GetMessage() + { + return "Hello from HelperBuiltIn1 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn2.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn2.cs new file mode 100644 index 000000000..5ba00add3 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/HelperBuiltIn2.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class HelperBuiltIn2 + { + public static string GetMessage() + { + return "Hello from HelperBuiltIn2 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/IncludeThis.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/IncludeThis.cs new file mode 100644 index 000000000..d9300fe2d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/IncludeThis.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class IncludeThis + { + public static string GetMessage() + { + return "Hello from IncludeThis class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/Program.cs new file mode 100644 index 000000000..bf3f8b064 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine(IncludeThis.GetMessage()); + Console.WriteLine(HelperBuiltIn1.GetMessage()); + Console.WriteLine(HelperBuiltIn2.GetMessage()); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/project.json new file mode 100644 index 000000000..7418df38c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileBuiltInOptions/project/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "compileBuiltIn": [ "Program.cs", "IncludeThis.cs", "../HelperBuiltIn1.cs", "../HelperBuiltIn2.cs" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs new file mode 100644 index 000000000..c8ee6c75e --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs @@ -0,0 +1 @@ +This does not compile but is used to test compile exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json new file mode 100644 index 000000000..5c81a68c2 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "compileExclude": "ExcludeThis.cs", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper1.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper1.cs new file mode 100644 index 000000000..dd2447c0f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper1.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Helper1 + { + public static string GetMessage() + { + return "Hello from Helper1 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper2.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper2.cs new file mode 100644 index 000000000..eeabb8a3d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/Helper2.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Helper2 + { + public static string GetMessage() + { + return "Hello from Helper2 class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/IncludeThis.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/IncludeThis.cs new file mode 100644 index 000000000..d9300fe2d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/IncludeThis.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class IncludeThis + { + public static string GetMessage() + { + return "Hello from IncludeThis class!"; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/Program.cs new file mode 100644 index 000000000..67d7bea12 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine(IncludeThis.GetMessage()); + Console.WriteLine(Helper1.GetMessage()); + Console.WriteLine(Helper2.GetMessage()); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/project.json new file mode 100644 index 000000000..87eeadaa3 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileOptions/project/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "compile": "../Helper1.cs", + "compileFiles": "../Helper2.cs", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index 07d48eb88..e5839c949 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -246,5 +246,143 @@ namespace Microsoft.DotNet.Migration.Tests Directory.Exists(Path.Combine(publishDir.FullName, "IncludeThis2.txt")).Should().BeFalse(); Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis.txt")).Should().BeFalse(); } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'compileFiles' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compileBuiltIn' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileBuiltInOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileBuiltInOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + //Issue: https://github.com/dotnet/cli/issues/5467 + //new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .Execute("build") + // .Should().Pass(); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'compileExclude' option is deprecated. Use 'compile' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedCompileExcludeOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileExcludeOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + // Issue: https://github.com/dotnet/cli/issues/5461 + //new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .Execute("build") + // .Should().Pass(); + } } } From 8b7c0ad4685f10267d72cacdc618a4489d8148db Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 09:15:30 -0800 Subject: [PATCH 05/10] Add more tests --- .../{ExcludeThis.cs => ExcludeThis1.cs} | 0 .../ExcludeThis2.cs | 1 + .../project.json | 3 +- .../Strings1.resx | 123 ++++++++++++++ .../Strings2.resx | 123 ++++++++++++++ .../project/Program.cs | 19 +++ .../project/Resources/Strings.resx | 123 ++++++++++++++ .../project/project.json | 20 +++ .../Exclude1.resx | 1 + .../Exclude2.resx | 1 + .../Program.cs | 19 +++ .../project.json | 21 +++ .../Strings1.resx | 123 ++++++++++++++ .../Strings2.resx | 123 ++++++++++++++ .../project/Program.cs | 19 +++ .../project/Resources/Strings.resx | 123 ++++++++++++++ .../project/project.json | 21 +++ ...venThatIWantToMigrateDeprecatedProjects.cs | 158 ++++++++++++++++++ 18 files changed, 1020 insertions(+), 1 deletion(-) rename TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/{ExcludeThis.cs => ExcludeThis1.cs} (100%) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis2.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings1.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings2.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Resources/Strings.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude1.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude2.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/project.json create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings1.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings2.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Resources/Strings.resx create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/project.json diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis1.cs similarity index 100% rename from TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis.cs rename to TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis1.cs diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis2.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis2.cs new file mode 100644 index 000000000..c8ee6c75e --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/ExcludeThis2.cs @@ -0,0 +1 @@ +This does not compile but is used to test compile exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json index 5c81a68c2..3b457a6dc 100644 --- a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedCompileExcludeOptions/project.json @@ -1,6 +1,7 @@ { "version": "1.0.0-*", - "compileExclude": "ExcludeThis.cs", + "compileExclude": "ExcludeThis1.cs", + "exclude": [ "ExcludeThis2.cs" ], "buildOptions": { "debugType": "portable", "emitEntryPoint": true diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings1.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings1.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings2.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings2.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/Strings2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Resources/Strings.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Resources/Strings.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/Resources/Strings.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/project.json new file mode 100644 index 000000000..d4f8ee07f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceBuiltInOptions/project/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "resourceBuiltIn": [ "../Strings1.resx", "../Strings2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude1.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude1.resx new file mode 100644 index 000000000..a82c91ddd --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude1.resx @@ -0,0 +1 @@ +This is not a resource file but is used to test resource exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude2.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude2.resx new file mode 100644 index 000000000..a82c91ddd --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Exclude2.resx @@ -0,0 +1 @@ +This is not a resource file but is used to test resource exclusion. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/project.json new file mode 100644 index 000000000..01c3c9e23 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceExcludeOptions/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "exclude": "Exclude1.resx", + "resourceExclude": [ "Exclude2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings1.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings1.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings2.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings2.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/Strings2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Resources/Strings.resx b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Resources/Strings.resx new file mode 100644 index 000000000..1f24a372f --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/Resources/Strings.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/project.json new file mode 100644 index 000000000..369f7325d --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedResourceOptions/project/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "resource": "../Strings1.resx", + "resourceFiles": [ "../Strings2.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index e5839c949..d5dcad063 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -384,5 +384,163 @@ namespace Microsoft.DotNet.Migration.Tests // .Execute("build") // .Should().Pass(); } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resource' option is deprecated. Use 'embed' in 'buildOptions' instead."); + cmd.StdOut.Should().Contain( + "The 'resourceFiles' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("run"); + cmd.Should().Pass(); + cmd.StdOut.Should().Contain("3 Resources Found:"); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceBuiltInOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceBuiltInOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resourceBuiltIn' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceBuiltInOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceBuiltInOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project"); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("build") + .Should().Pass(); + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("run"); + cmd.Should().Pass(); + // Issue: https://github.com/dotnet/cli/issues/5467 + //cmd.StdOut.Should().Contain("2 Resources Found:"); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceExcludeOptionsWarningsArePrinted() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceExcludeOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + var cmd = new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .ExecuteWithCapturedOutput("migrate"); + + cmd.Should().Pass(); + + cmd.StdOut.Should().Contain( + "The 'resourceExclude' option is deprecated. Use 'embed' in 'buildOptions' instead."); + } + + [Fact] + public void WhenMigratingAProjectWithDeprecatedResourceExcludeOptionsItSucceeds() + { + var projectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceExcludeOptions") + .CreateInstance() + .WithSourceFiles() + .Root; + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("migrate") + .Should().Pass(); + + new DotnetCommand() + .WithWorkingDirectory(projectDirectory) + .Execute("restore") + .Should().Pass(); + + // Issue: https://github.com/dotnet/cli/issues/5461 + //new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .Execute("build") + // .Should().Pass(); + + //var cmd = new DotnetCommand() + // .WithWorkingDirectory(projectDirectory) + // .ExecuteWithCapturedOutput("run"); + //cmd.Should().Pass(); + //cmd.StdOut.Should().Contain("0 Resources Found:"); + } } } From 61ae452fe2548314932c72230c9331e4a566dc06 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 09:55:09 -0800 Subject: [PATCH 06/10] Updating tests --- .../project/{ExcludeThis.txt => ExcludeThis1.txt} | 0 .../project/ExcludeThis2.txt | 1 + .../project/{IncludeThis1.txt => IncludeThis.txt} | 0 .../project/IncludeThis2.txt | 1 - .../project/project.json | 4 ++-- .../GivenThatIWantToMigrateDeprecatedProjects.cs | 12 ++++++------ 6 files changed, 9 insertions(+), 9 deletions(-) rename TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/{ExcludeThis.txt => ExcludeThis1.txt} (100%) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis2.txt rename TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/{IncludeThis1.txt => IncludeThis.txt} (100%) delete mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis1.txt similarity index 100% rename from TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis.txt rename to TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis1.txt diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis2.txt new file mode 100644 index 000000000..949ca7b7c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/ExcludeThis2.txt @@ -0,0 +1 @@ +Test content file that should be excluded. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis.txt similarity index 100% rename from TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis1.txt rename to TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis.txt diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt deleted file mode 100644 index 49852374c..000000000 --- a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/IncludeThis2.txt +++ /dev/null @@ -1 +0,0 @@ -Test content file that should be included. diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json index 15c8a8cbe..bf61a22e2 100644 --- a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedContentOptions/project/project.json @@ -1,10 +1,10 @@ { "version": "1.0.0-*", "content": "*.txt", - "contentExclude": "ExcludeThis.txt", + "contentExclude": "ExcludeThis1.txt", "contentFiles": [ "../ContentFile1.txt", "../ContentFile2.txt" ], "contentBuiltIn": [ "../ContentFileBuiltIn1.txt", "../ContentFileBuiltIn2.txt" ], - "publishExclude": "IncludeThis2.txt", + "publishExclude": "ExcludeThis2.txt", "buildOptions": { "debugType": "portable", "emitEntryPoint": true diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index d5dcad063..419f50f29 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -228,10 +228,10 @@ namespace Microsoft.DotNet.Migration.Tests "ContentFile2.txt", "ContentFileBuiltIn1.txt", "ContentFileBuiltIn2.txt", - "IncludeThis1.txt", + "IncludeThis.txt", }); - Directory.Exists(Path.Combine(outputDir.FullName, "IncludeThis2.txt")).Should().BeFalse(); - Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis1.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis2.txt")).Should().BeFalse(); var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish"); publishDir.Should().Exist() @@ -241,10 +241,10 @@ namespace Microsoft.DotNet.Migration.Tests "ContentFile2.txt", "ContentFileBuiltIn1.txt", "ContentFileBuiltIn2.txt", - "IncludeThis1.txt", + "IncludeThis.txt", }); - Directory.Exists(Path.Combine(publishDir.FullName, "IncludeThis2.txt")).Should().BeFalse(); - Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis1.txt")).Should().BeFalse(); + Directory.Exists(Path.Combine(publishDir.FullName, "ExcludeThis2.txt")).Should().BeFalse(); } [Fact] From 037da3fc014214764ed64ed2cece7392743b385d Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 11:00:50 -0800 Subject: [PATCH 07/10] Finish tests --- .../Program.cs | 19 ++++++++++++++ .../project.json | 20 ++++++++++++++ .../ProjectReader.cs | 15 ++++++++--- .../ProjectMigrator.cs | 25 ++++++++++++++---- .../GivenAProjectMigrator.cs | 26 +++++++++++++++++++ 5 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/project.json diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/Program.cs b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/Program.cs new file mode 100644 index 000000000..d0134277c --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using System.Reflection; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + var thisAssembly = typeof(Program).GetTypeInfo().Assembly; + var resources = from resourceName in thisAssembly.GetManifestResourceNames() + select resourceName; + + var resourceNames = string.Join(",", resources); + Console.WriteLine($"{resources.Count()} Resources Found: {resourceNames}"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/project.json b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/project.json new file mode 100644 index 000000000..0bf0dfa00 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/PJAppWithDeprecatedNamedResourceOption/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.0.0-*", + "namedResource": [ "My.Alias", "Strings.resx" ], + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 2c6e07710..1b20a58af 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -825,7 +825,14 @@ namespace Microsoft.DotNet.Internal.ProjectModel AddDeprecatedDiagnosticMessage(rawProject, project, "resourceExclude", resourceWarning); AddDeprecatedDiagnosticMessage(rawProject, project, "resourceFiles", resourceWarning); AddDeprecatedDiagnosticMessage(rawProject, project, "resourceBuiltIn", resourceWarning); - AddDeprecatedDiagnosticMessage(rawProject, project, "namedResource", resourceWarning); + // Issue: https://github.com/dotnet/cli/issues/5471 + // This is why we mark it as an error which will fail migration. + AddDeprecatedDiagnosticMessage( + rawProject, + project, + "namedResource", + resourceWarning, + DiagnosticMessageSeverity.Error); var contentWarning = "'publishOptions' to publish or 'copyToOutput' in 'buildOptions' to copy to build output"; AddDeprecatedDiagnosticMessage(rawProject, project, "content", contentWarning); @@ -842,7 +849,8 @@ namespace Microsoft.DotNet.Internal.ProjectModel JObject rawProject, Project project, string option, - string message) + string message, + DiagnosticMessageSeverity severity = DiagnosticMessageSeverity.Warning) { var lineInfo = rawProject.Value(option); if (lineInfo == null) @@ -855,7 +863,7 @@ namespace Microsoft.DotNet.Internal.ProjectModel ErrorCodes.DOTNET1015, $"The '{option}' option is deprecated. Use {message} instead.", project.ProjectFilePath, - DiagnosticMessageSeverity.Warning, + severity, lineInfo.LineNumber, lineInfo.LinePosition)); } @@ -896,7 +904,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel ConvertFromDeprecatedFormat(rawProject, jpath, "exclude", "exclude"); ConvertFromDeprecatedFormat(rawProject, jpath, "resourceExclude", "excludeFiles"); ConvertFromDeprecatedFormat(rawProject, jpath, "resourceFiles", "includeFiles"); - ConvertFromDeprecatedFormat(rawProject, jpath, "namedResource", "mappings"); ConvertFromDeprecatedFormat(rawProject, $"{jpath}.builtIns", "resourceBuiltIn", "include"); } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 7b2a31446..37cc20b50 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -252,11 +252,26 @@ namespace Microsoft.DotNet.ProjectJsonMigration var diagnostics = defaultProjectContext.ProjectFile.Diagnostics; if (diagnostics.Any()) { - var deprecatedProjectJsonWarnings = string.Join( - Environment.NewLine, - diagnostics.Select(d => FormatDiagnosticMessage(d))); - var warnings = $"{projectDirectory}{Environment.NewLine}{deprecatedProjectJsonWarnings}"; - Reporter.Output.WriteLine(warnings.Yellow()); + var warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning); + if (warnings.Any()) + { + var deprecatedProjectJsonWarnings = string.Join( + Environment.NewLine, + diagnostics.Select(d => FormatDiagnosticMessage(d))); + var warningMessage = $"{projectDirectory}{Environment.NewLine}{deprecatedProjectJsonWarnings}"; + Reporter.Output.WriteLine(warningMessage.Yellow()); + } + + var errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error); + if (errors.Any()) + { + MigrationErrorCodes.MIGRATE1011(String.Format( + "{0}{1}{2}", + projectDirectory, + Environment.NewLine, + string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))) + .Throw(); + } } var compilerName = diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs index d1cb75935..e0111f385 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs @@ -6,6 +6,7 @@ using FluentAssertions; using Microsoft.Build.Construction; using Microsoft.DotNet.ProjectJsonMigration.Rules; using Microsoft.DotNet.Internal.ProjectModel; +using Microsoft.DotNet.TestFramework; using Microsoft.DotNet.Tools.Common; using Microsoft.DotNet.Tools.Test.Utilities; using NuGet.Frameworks; @@ -38,6 +39,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } } + [Fact] + public void ItHasErrorWhenMigratingADeprecatedNamedResourceOptionProjectJson() + { + var testProjectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedNamedResourceOption") + .CreateInstance() + .WithSourceFiles() + .Root + .FullName; + + var mockProj = ProjectRootElement.Create(); + var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( + testProjectDirectory, + testProjectDirectory, + mockProj); + + var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); + var report = projectMigrator.Migrate(testSettings); + + var projectReport = report.ProjectMigrationReports.First(); + var errorMessage = projectReport.Errors.First().GetFormattedErrorMessage(); + errorMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); + errorMessage.Should().Contain("The 'namedResource' option is deprecated. Use 'embed' in 'buildOptions' instead. (line: 3, file:"); + } + [Fact] public void ItHasErrorWhenMigratingANonCsharpApp() { From 3821d39d6cdc46b64b8b97e1a873e9a69b3c3296 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 12:53:29 -0800 Subject: [PATCH 08/10] Address PR comments --- .../ProjectReader.cs | 30 +++++++-------- .../ProjectMigrator.cs | 38 +++++++++++++------ .../commands/dotnet-migrate/MigrateCommand.cs | 17 +++++++++ .../GivenAProjectMigrator.cs | 26 +++++++++++++ ...venThatIWantToMigrateDeprecatedProjects.cs | 8 ++-- 5 files changed, 88 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index 1b20a58af..7a2778d9c 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -955,6 +955,21 @@ namespace Microsoft.DotNet.Internal.ProjectModel return (rawProject.SelectToken(jpathToNewFormatObject) != null); } + private static void ConvertFromDeprecatedFormat( + JObject rawProject, + string jpathToObject, + string deprecatedKey, + string newKey + ) + { + var deprecatedValue = rawProject.Value(deprecatedKey); + if (deprecatedValue != null) + { + var objectNode = GetOrCreateObjectHierarchy(rawProject, jpathToObject); + objectNode[newKey] = deprecatedValue.DeepClone(); + } + } + private static JObject GetOrCreateObjectHierarchy(JObject rawProject, string jpath) { var currentObject = rawProject as JObject; @@ -973,21 +988,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel return currentObject; } - - private static void ConvertFromDeprecatedFormat( - JObject rawProject, - string jpathToObject, - string deprecatedKey, - string newKey - ) - { - var deprecatedValue = rawProject.Value(deprecatedKey); - if (deprecatedValue != null) - { - var objectNode = GetOrCreateObjectHierarchy(rawProject, jpathToObject); - objectNode[newKey] = deprecatedValue.DeepClone(); - } - } private static bool TryGetStringEnumerable(JToken token, out IEnumerable result) { diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 37cc20b50..2554ee9c8 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -42,10 +42,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration IEnumerable projectDependencies = null; var projectMigrationReports = new List(); + List warnings = null; try { // Verify up front so we can prefer these errors over an unresolved project dependency - VerifyInputs(rootInputs, rootSettings); + VerifyInputs(rootInputs, rootSettings, out warnings); projectMigrationReports.Add(MigrateProject(rootSettings)); @@ -68,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration rootSettings.ProjectDirectory, rootInputs?.DefaultProjectContext?.GetProjectName(), new List {e.Error}, - null) + warnings) }); } @@ -144,6 +145,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration var projectName = migrationRuleInputs.DefaultProjectContext.GetProjectName(); var outputProject = Path.Combine(migrationSettings.OutputDirectory, projectName + ".csproj"); + List warnings = null; try { if (File.Exists(outputProject)) @@ -166,7 +168,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration } } - VerifyInputs(migrationRuleInputs, migrationSettings); + VerifyInputs(migrationRuleInputs, migrationSettings, out warnings); SetupOutputDirectory(migrationSettings.ProjectDirectory, migrationSettings.OutputDirectory); @@ -179,7 +181,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration exc.Error }; - return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, null); + return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, warnings); } List csprojDependencies = null; @@ -208,7 +210,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration projectName, outputProject, null, - null, + warnings, csprojDependencies); } @@ -235,13 +237,22 @@ namespace Microsoft.DotNet.ProjectJsonMigration return new MigrationRuleInputs(projectContexts, templateMSBuildProject, itemGroup, propertyGroup, xproj); } - private void VerifyInputs(MigrationRuleInputs migrationRuleInputs, MigrationSettings migrationSettings) + private void VerifyInputs( + MigrationRuleInputs migrationRuleInputs, + MigrationSettings migrationSettings, + out List warningMessages + ) { - VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory); + VerifyProject(migrationRuleInputs.ProjectContexts, migrationSettings.ProjectDirectory, out warningMessages); } - private void VerifyProject(IEnumerable projectContexts, string projectDirectory) + private void VerifyProject( + IEnumerable projectContexts, + string projectDirectory, + out List warningMessages) { + warningMessages = null; + if (!projectContexts.Any()) { MigrationErrorCodes.MIGRATE1013(String.Format(LocalizableStrings.MIGRATE1013Arg, projectDirectory)).Throw(); @@ -255,11 +266,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration var warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning); if (warnings.Any()) { - var deprecatedProjectJsonWarnings = string.Join( + var migrationError = MigrationErrorCodes.MIGRATE1011(String.Format( + "{0}{1}{2}", + projectDirectory, Environment.NewLine, - diagnostics.Select(d => FormatDiagnosticMessage(d))); - var warningMessage = $"{projectDirectory}{Environment.NewLine}{deprecatedProjectJsonWarnings}"; - Reporter.Output.WriteLine(warningMessage.Yellow()); + string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d))))); + + warningMessages = new List(); + warningMessages.Add(migrationError.GetFormattedErrorMessage()); } var errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error); diff --git a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs index b50aca8d1..196339c1f 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -262,6 +262,8 @@ namespace Microsoft.DotNet.Tools.Migrate { var errorContent = GetProjectReportErrorContent(projectMigrationReport, colored: true); var successContent = GetProjectReportSuccessContent(projectMigrationReport, colored: true); + var warningContent = GetProjectReportWarningContent(projectMigrationReport, colored: true); + Reporter.Output.WriteLine(warningContent); if (!string.IsNullOrEmpty(errorContent)) { Reporter.Error.WriteLine(errorContent); @@ -290,6 +292,8 @@ namespace Microsoft.DotNet.Tools.Migrate { var errorContent = GetProjectReportErrorContent(projectMigrationReport, colored: colored); var successContent = GetProjectReportSuccessContent(projectMigrationReport, colored: colored); + var warningContent = GetProjectReportWarningContent(projectMigrationReport, colored: colored); + sb.AppendLine(warningContent); if (!string.IsNullOrEmpty(errorContent)) { sb.AppendLine(errorContent); @@ -331,6 +335,19 @@ namespace Microsoft.DotNet.Tools.Migrate projectMigrationReport.ProjectDirectory)); } + private string GetProjectReportWarningContent(ProjectMigrationReport projectMigrationReport, bool colored) + { + StringBuilder sb = new StringBuilder(); + Func YellowIfColored = (str) => colored ? str.Yellow() : str; + + foreach (var warning in projectMigrationReport.Warnings) + { + sb.AppendLine(YellowIfColored(warning)); + } + + return sb.ToString(); + } + private string GetProjectReportErrorContent(ProjectMigrationReport projectMigrationReport, bool colored) { StringBuilder sb = new StringBuilder(); diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs index e0111f385..e6ca62262 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/GivenAProjectMigrator.cs @@ -39,6 +39,32 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } } + [Fact] + public void ItHasWarningWhenMigratingADeprecatedProjectJson() + { + var testProjectDirectory = TestAssets + .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedCompileOptions") + .CreateInstance() + .WithSourceFiles() + .Root + .GetDirectory("project") + .FullName; + + var mockProj = ProjectRootElement.Create(); + var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( + testProjectDirectory, + testProjectDirectory, + mockProj); + + var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); + var report = projectMigrator.Migrate(testSettings); + + var projectReport = report.ProjectMigrationReports.First(); + var warningMessage = projectReport.Warnings.First(); + warningMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); + warningMessage.Should().Contain("The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead. (line: 3, file:"); + } + [Fact] public void ItHasErrorWhenMigratingADeprecatedNamedResourceOptionProjectJson() { diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index 419f50f29..3229a333e 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -72,12 +72,12 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("pack") + .Execute("pack -c Debug") .Should().Pass(); var outputDir = projectDirectory.GetDirectory("bin", "Debug"); @@ -212,12 +212,12 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("publish") + .Execute("publish -c Debug") .Should().Pass(); var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0"); From d87653a7c67ae2ce2b42fed4f9787d6de92f9992 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 14:32:41 -0800 Subject: [PATCH 09/10] Update tests --- ...venThatIWantToMigrateDeprecatedProjects.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index 3229a333e..ba8b049c1 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -161,7 +161,7 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); } @@ -290,7 +290,7 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); } @@ -336,7 +336,7 @@ namespace Microsoft.DotNet.Migration.Tests //Issue: https://github.com/dotnet/cli/issues/5467 //new DotnetCommand() // .WithWorkingDirectory(projectDirectory) - // .Execute("build") + // .Execute("build -c Debug") // .Should().Pass(); } @@ -381,7 +381,7 @@ namespace Microsoft.DotNet.Migration.Tests // Issue: https://github.com/dotnet/cli/issues/5461 //new DotnetCommand() // .WithWorkingDirectory(projectDirectory) - // .Execute("build") + // .Execute("build -c Debug") // .Should().Pass(); } @@ -429,12 +429,12 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); var cmd = new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .ExecuteWithCapturedOutput("run"); + .ExecuteWithCapturedOutput("run -c Debug"); cmd.Should().Pass(); cmd.StdOut.Should().Contain("3 Resources Found:"); } @@ -481,12 +481,12 @@ namespace Microsoft.DotNet.Migration.Tests new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .Execute("build") + .Execute("build -c Debug") .Should().Pass(); var cmd = new DotnetCommand() .WithWorkingDirectory(projectDirectory) - .ExecuteWithCapturedOutput("run"); + .ExecuteWithCapturedOutput("run -c Debug"); cmd.Should().Pass(); // Issue: https://github.com/dotnet/cli/issues/5467 //cmd.StdOut.Should().Contain("2 Resources Found:"); @@ -533,12 +533,12 @@ namespace Microsoft.DotNet.Migration.Tests // Issue: https://github.com/dotnet/cli/issues/5461 //new DotnetCommand() // .WithWorkingDirectory(projectDirectory) - // .Execute("build") + // .Execute("build -c Debug") // .Should().Pass(); //var cmd = new DotnetCommand() // .WithWorkingDirectory(projectDirectory) - // .ExecuteWithCapturedOutput("run"); + // .ExecuteWithCapturedOutput("run -c Debug"); //cmd.Should().Pass(); //cmd.StdOut.Should().Contain("0 Resources Found:"); } From 835bc5bae1a0114186d3aa8be01db17d7a8d3900 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 26 Jan 2017 15:26:55 -0800 Subject: [PATCH 10/10] Shorten test name --- .../GivenThatIWantToMigrateDeprecatedProjects.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs index ba8b049c1..c80911fc7 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateDeprecatedProjects.cs @@ -460,7 +460,7 @@ namespace Microsoft.DotNet.Migration.Tests } [Fact] - public void WhenMigratingAProjectWithDeprecatedResourceBuiltInOptionsItSucceeds() + public void WhenMigratingDeprecatedBuiltInResItSucceeds() { var projectDirectory = TestAssets .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJAppWithDeprecatedResourceBuiltInOptions")