From b6603117725781aea97d23beaec6fc44edc1d19a Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 22 Feb 2017 23:16:54 -0800 Subject: [PATCH] Switching the CopyToOutput for build and publish and the file for pack to use None Update instead of include. Also, fixed the exclude patterns for web apps. --- .../Rules/ItemsIncludedInTheWebSDK.cs | 16 +++ .../Rules/MigrateBuildOptionsRule.cs | 12 +- .../Rules/MigratePackOptionsRule.cs | 2 +- .../Rules/MigratePublishOptionsRule.cs | 12 +- .../Transforms/ItemTransformApplicator.cs | 2 +- .../GivenThatIWantToMigrateBuildOptions.cs | 80 ++++++++++++- .../GivenThatIWantToMigrateConfigurations.cs | 111 ++++++++++-------- .../GivenThatIWantToMigratePackOptions.cs | 8 +- .../GivenThatIWantToMigratePublishOptions.cs | 35 +++--- 9 files changed, 175 insertions(+), 103 deletions(-) create mode 100644 src/Microsoft.DotNet.ProjectJsonMigration/Rules/ItemsIncludedInTheWebSDK.cs diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/ItemsIncludedInTheWebSDK.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/ItemsIncludedInTheWebSDK.cs new file mode 100644 index 000000000..e2432fc61 --- /dev/null +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/ItemsIncludedInTheWebSDK.cs @@ -0,0 +1,16 @@ +// 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. + +namespace Microsoft.DotNet.ProjectJsonMigration.Rules +{ + internal class ItemsIncludedInTheWebSDK + { + public static bool HasContent(string content) + { + return content.Equals("wwwroot") || + content.Contains("web.config") || + content.Equals("**/*.cshtml") || + content.Contains(".json"); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs index 3193c6de2..45f1f6583 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateBuildOptionsRule.cs @@ -147,14 +147,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules new RemoveContextTransform("EmbeddedResource", condition: ic => ic != null); private IncludeContextTransform CopyToOutputFilesTransform => - new IncludeContextTransform("None", transformMappings: true) + new UpdateContextTransform("None", transformMappings: true) .WithMetadata("CopyToOutputDirectory", "PreserveNewest"); private IncludeContextTransform CopyToOutputFilesTransformForWeb => new UpdateContextTransform( "None", transformMappings: true, - excludePatternsRule: pattern => PatternIncludedInWebSdk(pattern)) + excludePatternsRule: pattern => ItemsIncludedInTheWebSDK.HasContent(pattern)) .WithMetadata("CopyToOutputDirectory", "PreserveNewest"); private AddPropertyTransform GenerateRuntimeConfigurationFilesTransform => @@ -229,14 +229,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules ConstructTransformLists(); } - private bool PatternIncludedInWebSdk(string pattern) - { - return pattern.Equals("wwwroot") || - pattern.Contains("web.config") || - pattern.Equals("**/*.cshtml") || - pattern.Contains(".json"); - } - private bool ContainsCompilerResources(string projectDirectory) { return Directory.Exists(Path.Combine(projectDirectory, "compiler", "resources")); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs index 32b3a6a26..c1258b427 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePackOptionsRule.cs @@ -57,7 +57,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules packOptions => !string.IsNullOrEmpty(packOptions.RepositoryUrl)); private IncludeContextTransform PackFilesTransform => - new IncludeContextTransform("None", transformMappings: true) + new UpdateContextTransform("None", transformMappings: true) .WithMetadata("Pack", "true") .WithMappingsToTransform(_mappingsToTransfrom); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs index 9e1429a96..2026809d8 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigratePublishOptionsRule.cs @@ -41,22 +41,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules } private IncludeContextTransform CopyToPublishDirectoryTransform => - new IncludeContextTransform("None", transformMappings: true) + new UpdateContextTransform("None", transformMappings: true) .WithMetadata("CopyToPublishDirectory", "PreserveNewest"); private IncludeContextTransform CopyToPublishDirectoryTransformForWeb => new UpdateContextTransform( "None", transformMappings: true, - excludePatternsRule: pattern => PatternIncludedInWebSdk(pattern)) + excludePatternsRule: pattern => ItemsIncludedInTheWebSDK.HasContent(pattern)) .WithMetadata("CopyToPublishDirectory", "PreserveNewest"); - - private bool PatternIncludedInWebSdk(string pattern) - { - return pattern.Equals("wwwroot/**") || - pattern.Equals("**/web.config") || - pattern.Equals("**/*.cshtml") || - pattern.Equals("**/*.json"); - } } } diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs index c5b60b4c1..26be01e4e 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Transforms/ItemTransformApplicator.cs @@ -233,7 +233,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms LocalizableStrings.ItemTransformApplicatorEncompassedUpdates, nameof(ItemTransformApplicator), string.Join(", ", encompassedUpdates))); - existingItem.RemoveIncludes(encompassedUpdates); + existingItem.RemoveUpdates(encompassedUpdates); } // continue if the existing item is now empty diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs index 679d81a54..346dcf04a 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateBuildOptions.cs @@ -477,7 +477,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests [Theory] [InlineData("compile", "Compile", 3, "")] [InlineData("embed", "EmbeddedResource", 3, ";rootfile.cs")] - [InlineData("copyToOutput", "None", 2, ";rootfile.cs")] public void MigratingGroupIncludeExcludePopulatesAppropriateProjectItemElement( string group, string itemName, @@ -514,8 +513,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests if (string.IsNullOrEmpty(item.Include)) { - item.Remove.Should() - .Be(@"src\**\*;rootfile.cs;src\file2.cs"); + item.Remove.Should() + .Be(@"src\**\*;rootfile.cs;src\file2.cs"); } else if (item.Include.Contains(@"src\file1.cs")) { @@ -550,10 +549,56 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } } + [Theory] + [InlineData("copyToOutput", "None", 2, ";rootfile.cs")] + public void MigratingCopyToOutputIncludeExcludePopulatesAppropriateProjectItemElement( + string group, + string itemName, + int expectedNumberOfCompileItems, + string expectedRootFiles) + { + var testDirectory = Temp.CreateDirectory().Path; + WriteExtraFiles(testDirectory); + + var pj = @" + { + ""buildOptions"": { + """": { + ""include"": [""root"", ""src"", ""rootfile.cs""], + ""exclude"": [""src"", ""rootfile.cs""], + ""includeFiles"": [""src/file1.cs"", ""src/file2.cs""], + ""excludeFiles"": [""src/file2.cs""] + } + } + }".Replace("", group); + + var mockProj = RunBuildOptionsRuleOnPj(pj, + testDirectory: testDirectory); + + mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)) + .Should().Be(expectedNumberOfCompileItems); + + foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals(itemName, StringComparison.Ordinal))) + { + VerifyContentMetadata(item); + + if (string.IsNullOrEmpty(item.Update)) + { + } + else if (item.Update.Contains(@"src\file1.cs")) + { + item.Update.Should().Be(@"src\file1.cs;src\file2.cs"); + } + else + { + item.Update.Should().Be(@"root\**\*;src\**\*;rootfile.cs"); + } + } + } + [Theory] [InlineData("compile", "Compile", "")] [InlineData("embed", "EmbeddedResource", ";rootfile.cs")] - [InlineData("copyToOutput", "None", ";rootfile.cs")] public void MigratingGroupIncludeOnlyPopulatesAppropriateProjectItemElement( string group, string itemName, @@ -572,8 +617,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var mockProj = RunBuildOptionsRuleOnPj(pj, testDirectory: testDirectory); - Console.WriteLine(mockProj.RawXml); - mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(1); var defaultIncludePatterns = GetDefaultIncludePatterns(group); @@ -607,6 +650,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests } } + [Theory] + [InlineData("copyToOutput", "None", ";rootfile.cs")] + public void MigratingCopyToOutputIncludeOnlyPopulatesAppropriateProjectItemElement( + string group, + string itemName, + string expectedRootFiles) + { + var testDirectory = Temp.CreateDirectory().Path; + WriteExtraFiles(testDirectory); + + var pj = @" + { + ""buildOptions"": { + """": [""root"", ""src"", ""rootfile.cs""] + } + }".Replace("", group); + + var mockProj = RunBuildOptionsRuleOnPj(pj, + testDirectory: testDirectory); + + mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(1); + + mockProj.Items.Single().Update.Should().Be($@"root\**\*;src\**\*{expectedRootFiles}"); + } + [Fact] public void MigratingTestProjectAddsGenerateRuntimeConfigurationFiles() { diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs index 16e8dc9f1..485eb56d8 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs @@ -178,23 +178,23 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var contentItems = mockProj.Items.Where(item => item.ItemType == "None"); - contentItems.Count().Should().Be(4); + contentItems.Count().Should().Be(3); // 2 for Base Build options contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2); - // 2 for Configuration BuildOptions (1 Remove, 1 Include) - contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(2); + // 2 for Configuration BuildOptions (1 Remove, 1 Update) + contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(1); var configIncludeContentItem = contentItems.First( - item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Include)); - var configRemoveContentItem = contentItems.First( - item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); + item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Update)); + //var configRemoveContentItem = contentItems.First( + // item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); // Directories are not converted to globs in the result because we did not write the directory - configRemoveContentItem.Remove.Should().Be(@"root;src;rootfile.cs"); - configIncludeContentItem.Include.Should().Be(@"root;src;rootfile.cs"); - configIncludeContentItem.Exclude.Should().Be(@"src;root\rootfile.cs;src\file2.cs"); + //configRemoveContentItem.Remove.Should().Be(@"root;src;rootfile.cs"); + configIncludeContentItem.Update.Should().Be(@"root;rootfile.cs"); + //configIncludeContentItem.Exclude.Should().Be(@"src;root\rootfile.cs;src\file2.cs"); } [Fact] @@ -226,35 +226,46 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var contentItems = mockProj.Items.Where(item => item.ItemType == "None"); - contentItems.Count().Should().Be(5); + foreach(var c in contentItems) + { + Console.WriteLine($"Include: {c.Include}, Update: {c.Update}, Remove: {c.Remove}, Condition: {c.ConditionChain().Count()}"); + } + + contentItems.Count().Should().Be(3); // 2 for Base Build options contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2); - // 3 for Configuration BuildOptions (1 Remove, 2 Include) - contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(3); + // 3 for Configuration BuildOptions (1 Remove, 2 Update) + contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(1); var configIncludeContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains("root")); + && item.Update.Contains("root")); var configIncludeContentItem2 = contentItems.First( - item => item.ConditionChain().Count() > 0 - && item.Include.Contains(@"src\file1.cs")); + item => item.ConditionChain().Count() == 0 + && item.Update.Contains(@"src\file1.cs")); - var configRemoveContentItem = contentItems.First( - item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); + var configIncludeContentItem3 = contentItems.First( + item => item.ConditionChain().Count() == 0 + && item.Update.Equals(@"src")); + + //var configRemoveContentItem = contentItems.First( + // item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); // Directories are not converted to globs in the result because we did not write the directory - configRemoveContentItem.Removes() - .Should().BeEquivalentTo("root", "src", "rootfile.cs", @"src\file1.cs", @"src\file2.cs"); + //configRemoveContentItem.Removes() + // .Should().BeEquivalentTo("root", "src", "rootfile.cs", @"src\file1.cs", @"src\file2.cs"); - configIncludeContentItem.Includes().Should().BeEquivalentTo("root", "src", "rootfile.cs"); - configIncludeContentItem.Excludes() - .Should().BeEquivalentTo("rootfile.cs", "someotherfile.cs", @"src\file2.cs"); + configIncludeContentItem.Updates().Should().BeEquivalentTo("root", "rootfile.cs"); + //configIncludeContentItem.Excludes() + // .Should().BeEquivalentTo("rootfile.cs", "someotherfile.cs", @"src\file2.cs"); - configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs"); - configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs"); + configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs"); + //configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs"); + + configIncludeContentItem3.Updates().Should().BeEquivalentTo(@"src"); } [Fact] @@ -287,15 +298,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var configIncludeContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains("root")); + && item.Update.Contains("root")); var configIncludeContentItem2 = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains(@"src\file1.cs")); + && item.Update.Contains(@"src\file1.cs")); - configIncludeContentItem.Includes().Should().BeEquivalentTo("root", "src"); - configIncludeContentItem.Excludes() - .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs"); + configIncludeContentItem.Updates().Should().BeEquivalentTo("root", "src"); +// configIncludeContentItem.Excludes() +// .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs"); configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)"); @@ -303,8 +314,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest"); - configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs"); - configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs"); + configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs"); +// configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs"); configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull(); configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)"); @@ -345,36 +356,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var configIncludeContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include == "root"); + && item.Update == "root"); var configIncludeContentItem2 = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include == "src"); + && item.Update == "src"); var configIncludeContentItem3 = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains(@"src\file1.cs")); + && item.Update.Contains(@"src\file1.cs")); // Directories are not converted to globs in the result because we did not write the directory - configIncludeContentItem.Includes().Should().BeEquivalentTo("root"); - configIncludeContentItem.Excludes() - .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs"); + configIncludeContentItem.Updates().Should().BeEquivalentTo("root"); +// configIncludeContentItem.Excludes() +// .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs"); configIncludeContentItem.GetMetadataWithName("Link").Should().BeNull(); configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest"); - configIncludeContentItem2.Include.Should().Be("src"); - configIncludeContentItem2.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs"); + configIncludeContentItem2.Update.Should().Be("src"); +// configIncludeContentItem2.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs"); configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull(); configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)"); configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest"); - configIncludeContentItem3.Includes().Should().BeEquivalentTo(@"src\file1.cs"); - configIncludeContentItem3.Exclude.Should().Be(@"src\file2.cs"); + configIncludeContentItem3.Updates().Should().BeEquivalentTo(@"src\file1.cs"); +// configIncludeContentItem3.Exclude.Should().Be(@"src\file2.cs"); configIncludeContentItem3.GetMetadataWithName("Link").Should().BeNull(); configIncludeContentItem3.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); @@ -427,13 +438,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var configIncludeContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains("src")); + && item.Update.Contains("src")); var configRemoveContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); - configIncludeContentItem.Include.Should().Be("src"); + configIncludeContentItem.Update.Should().Be("src"); configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)"); @@ -492,31 +503,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests var configIncludeEncompassedItem = contentItems.FirstOrDefault( item => item.ConditionChain().Count() > 0 - && item.Include == "root"); + && item.Update == "root"); configIncludeEncompassedItem.Should().BeNull(); var configIncludeContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include == "src"); + && item.Update == "src"); var configIncludeContentItem2 = contentItems.First( item => item.ConditionChain().Count() > 0 - && item.Include.Contains(@"src\file3.cs")); + && item.Update.Contains(@"src\file3.cs")); var configRemoveContentItem = contentItems.First( item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove)); - configIncludeContentItem.Include.Should().Be("src"); - configIncludeContentItem.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs"); + configIncludeContentItem.Update.Should().Be("src"); + //configIncludeContentItem.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs"); configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)"); configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest"); - configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file3.cs"); - configIncludeContentItem2.Exclude.Should().Be(@"src\file2.cs"); + configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file3.cs"); + //configIncludeContentItem2.Exclude.Should().Be(@"src\file2.cs"); configIncludeContentItem2.GetMetadataWithName("Link").Should().BeNull(); configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull(); diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs index dd439d33b..73458594a 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs @@ -204,7 +204,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests .Where(item => item.GetMetadataWithName("Pack").Value == "true"); contentItems.Count().Should().Be(1); - contentItems.First().Include.Should().Be(@"path\to\some\file.cs;path\to\some\other\file.cs"); + contentItems.First().Update.Should().Be(@"path\to\some\file.cs;path\to\some\other\file.cs"); } [Fact] @@ -229,7 +229,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests item.GetMetadataWithName("PackagePath") != null); contentItems.Count().Should().Be(1); - contentItems.First().Include.Should().Be(@"path\to\some\file.cs"); + contentItems.First().Update.Should().Be(@"path\to\some\file.cs"); contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be( Path.Combine("some", "other", "path")); } @@ -256,7 +256,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests item.GetMetadataWithName("PackagePath") != null); contentItems.Count().Should().Be(1); - contentItems.First().Include.Should().Be(@"path\to\some\file.cs"); + contentItems.First().Update.Should().Be(@"path\to\some\file.cs"); contentItems.First().GetMetadataWithName("PackagePath").Value.Should().BeEmpty(); } @@ -290,7 +290,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests item.GetMetadataWithName("PackagePath") != null); contentItems.Count().Should().Be(1); - contentItems.First().Include.Should().Be(@"path\to\some\file.cs"); + contentItems.First().Update.Should().Be(@"path\to\some\file.cs"); contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(expectedPackagePath); } diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePublishOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePublishOptions.cs index 9b11d6618..8548e5208 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePublishOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePublishOptions.cs @@ -38,18 +38,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests { item.Metadata.Count(m => m.Name == "CopyToPublishDirectory").Should().Be(1); - if (item.Include.Contains(@"src\file1.cs")) + if (item.Update.Contains(@"src\file1.cs")) { - item.Include.Should().Be(@"src\file1.cs;src\file2.cs"); - item.Exclude.Should().Be(@"src\file2.cs"); + item.Update.Should().Be(@"src\file1.cs;src\file2.cs"); + item.Exclude.Should().BeEmpty(); } else { - item.Include.Should() - .Be(@"root\**\*;src\**\*;rootfile.cs"); - - item.Exclude.Should() - .Be(@"src\**\*;rootfile.cs;src\file2.cs"); + item.Update.Should().Be(@"root\**\*;src\**\*;rootfile.cs"); + item.Exclude.Should().BeEmpty(); } } } @@ -128,29 +125,25 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests mockProj.Items.Count(i => i.ItemType.Equals("None", StringComparison.Ordinal)).Should().Be(3); - // From ProjectReader #L725 (Both are empty) - var defaultIncludePatterns = Enumerable.Empty(); - var defaultExcludePatterns = Enumerable.Empty(); - foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals("None", StringComparison.Ordinal))) { - if (item.Include.Contains(@"root\**\*")) + if (item.Update.Contains(@"root\**\*")) { - item.Include.Should().Be(@"root\**\*"); - item.Exclude.Should().Be(@"src\**\*;rootfile.cs;src\file3.cs"); + item.Update.Should().Be(@"root\**\*"); + //item.Exclude.Should().Be(@"src\**\*;rootfile.cs;src\file3.cs"); } - else if (item.Include.Contains(@"src\file1.cs")) + else if (item.Update.Contains(@"src\file1.cs")) { - item.Include.Should().Be(@"src\file1.cs;src\file2.cs"); - item.Exclude.Should().Be(@"src\file2.cs;src\file3.cs"); + item.Update.Should().Be(@"src\file1.cs;src\file2.cs"); + //item.Exclude.Should().Be(@"src\file2.cs;src\file3.cs"); } else { - item.Include.Should() + item.Update.Should() .Be(@"src\**\*;rootfile.cs"); - item.Exclude.Should() - .Be(@"src\**\*;rootfile.cs;src\file2.cs;src\file3.cs"); + //item.Exclude.Should() + // .Be(@"src\**\*;rootfile.cs;src\file2.cs;src\file3.cs"); } } }