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.
This commit is contained in:
parent
1228c7ef55
commit
b660311772
9 changed files with 175 additions and 103 deletions
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -147,14 +147,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
new RemoveContextTransform("EmbeddedResource", condition: ic => ic != null);
|
new RemoveContextTransform("EmbeddedResource", condition: ic => ic != null);
|
||||||
|
|
||||||
private IncludeContextTransform CopyToOutputFilesTransform =>
|
private IncludeContextTransform CopyToOutputFilesTransform =>
|
||||||
new IncludeContextTransform("None", transformMappings: true)
|
new UpdateContextTransform("None", transformMappings: true)
|
||||||
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
|
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
|
||||||
|
|
||||||
private IncludeContextTransform CopyToOutputFilesTransformForWeb =>
|
private IncludeContextTransform CopyToOutputFilesTransformForWeb =>
|
||||||
new UpdateContextTransform(
|
new UpdateContextTransform(
|
||||||
"None",
|
"None",
|
||||||
transformMappings: true,
|
transformMappings: true,
|
||||||
excludePatternsRule: pattern => PatternIncludedInWebSdk(pattern))
|
excludePatternsRule: pattern => ItemsIncludedInTheWebSDK.HasContent(pattern))
|
||||||
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
|
.WithMetadata("CopyToOutputDirectory", "PreserveNewest");
|
||||||
|
|
||||||
private AddPropertyTransform<Project> GenerateRuntimeConfigurationFilesTransform =>
|
private AddPropertyTransform<Project> GenerateRuntimeConfigurationFilesTransform =>
|
||||||
|
@ -229,14 +229,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
ConstructTransformLists();
|
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)
|
private bool ContainsCompilerResources(string projectDirectory)
|
||||||
{
|
{
|
||||||
return Directory.Exists(Path.Combine(projectDirectory, "compiler", "resources"));
|
return Directory.Exists(Path.Combine(projectDirectory, "compiler", "resources"));
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
packOptions => !string.IsNullOrEmpty(packOptions.RepositoryUrl));
|
packOptions => !string.IsNullOrEmpty(packOptions.RepositoryUrl));
|
||||||
|
|
||||||
private IncludeContextTransform PackFilesTransform =>
|
private IncludeContextTransform PackFilesTransform =>
|
||||||
new IncludeContextTransform("None", transformMappings: true)
|
new UpdateContextTransform("None", transformMappings: true)
|
||||||
.WithMetadata("Pack", "true")
|
.WithMetadata("Pack", "true")
|
||||||
.WithMappingsToTransform(_mappingsToTransfrom);
|
.WithMappingsToTransform(_mappingsToTransfrom);
|
||||||
|
|
||||||
|
|
|
@ -41,22 +41,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
}
|
}
|
||||||
|
|
||||||
private IncludeContextTransform CopyToPublishDirectoryTransform =>
|
private IncludeContextTransform CopyToPublishDirectoryTransform =>
|
||||||
new IncludeContextTransform("None", transformMappings: true)
|
new UpdateContextTransform("None", transformMappings: true)
|
||||||
.WithMetadata("CopyToPublishDirectory", "PreserveNewest");
|
.WithMetadata("CopyToPublishDirectory", "PreserveNewest");
|
||||||
|
|
||||||
private IncludeContextTransform CopyToPublishDirectoryTransformForWeb =>
|
private IncludeContextTransform CopyToPublishDirectoryTransformForWeb =>
|
||||||
new UpdateContextTransform(
|
new UpdateContextTransform(
|
||||||
"None",
|
"None",
|
||||||
transformMappings: true,
|
transformMappings: true,
|
||||||
excludePatternsRule: pattern => PatternIncludedInWebSdk(pattern))
|
excludePatternsRule: pattern => ItemsIncludedInTheWebSDK.HasContent(pattern))
|
||||||
.WithMetadata("CopyToPublishDirectory", "PreserveNewest");
|
.WithMetadata("CopyToPublishDirectory", "PreserveNewest");
|
||||||
|
|
||||||
private bool PatternIncludedInWebSdk(string pattern)
|
|
||||||
{
|
|
||||||
return pattern.Equals("wwwroot/**") ||
|
|
||||||
pattern.Equals("**/web.config") ||
|
|
||||||
pattern.Equals("**/*.cshtml") ||
|
|
||||||
pattern.Equals("**/*.json");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
|
||||||
LocalizableStrings.ItemTransformApplicatorEncompassedUpdates,
|
LocalizableStrings.ItemTransformApplicatorEncompassedUpdates,
|
||||||
nameof(ItemTransformApplicator),
|
nameof(ItemTransformApplicator),
|
||||||
string.Join(", ", encompassedUpdates)));
|
string.Join(", ", encompassedUpdates)));
|
||||||
existingItem.RemoveIncludes(encompassedUpdates);
|
existingItem.RemoveUpdates(encompassedUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue if the existing item is now empty
|
// continue if the existing item is now empty
|
||||||
|
|
|
@ -477,7 +477,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("compile", "Compile", 3, "")]
|
[InlineData("compile", "Compile", 3, "")]
|
||||||
[InlineData("embed", "EmbeddedResource", 3, ";rootfile.cs")]
|
[InlineData("embed", "EmbeddedResource", 3, ";rootfile.cs")]
|
||||||
[InlineData("copyToOutput", "None", 2, ";rootfile.cs")]
|
|
||||||
public void MigratingGroupIncludeExcludePopulatesAppropriateProjectItemElement(
|
public void MigratingGroupIncludeExcludePopulatesAppropriateProjectItemElement(
|
||||||
string group,
|
string group,
|
||||||
string itemName,
|
string itemName,
|
||||||
|
@ -514,8 +513,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(item.Include))
|
if (string.IsNullOrEmpty(item.Include))
|
||||||
{
|
{
|
||||||
item.Remove.Should()
|
item.Remove.Should()
|
||||||
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
|
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
|
||||||
}
|
}
|
||||||
else if (item.Include.Contains(@"src\file1.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"": {
|
||||||
|
""<group>"": {
|
||||||
|
""include"": [""root"", ""src"", ""rootfile.cs""],
|
||||||
|
""exclude"": [""src"", ""rootfile.cs""],
|
||||||
|
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
|
||||||
|
""excludeFiles"": [""src/file2.cs""]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}".Replace("<group>", 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]
|
[Theory]
|
||||||
[InlineData("compile", "Compile", "")]
|
[InlineData("compile", "Compile", "")]
|
||||||
[InlineData("embed", "EmbeddedResource", ";rootfile.cs")]
|
[InlineData("embed", "EmbeddedResource", ";rootfile.cs")]
|
||||||
[InlineData("copyToOutput", "None", ";rootfile.cs")]
|
|
||||||
public void MigratingGroupIncludeOnlyPopulatesAppropriateProjectItemElement(
|
public void MigratingGroupIncludeOnlyPopulatesAppropriateProjectItemElement(
|
||||||
string group,
|
string group,
|
||||||
string itemName,
|
string itemName,
|
||||||
|
@ -572,8 +617,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
var mockProj = RunBuildOptionsRuleOnPj(pj,
|
var mockProj = RunBuildOptionsRuleOnPj(pj,
|
||||||
testDirectory: testDirectory);
|
testDirectory: testDirectory);
|
||||||
|
|
||||||
Console.WriteLine(mockProj.RawXml);
|
|
||||||
|
|
||||||
mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(1);
|
mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(1);
|
||||||
|
|
||||||
var defaultIncludePatterns = GetDefaultIncludePatterns(group);
|
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"": {
|
||||||
|
""<group>"": [""root"", ""src"", ""rootfile.cs""]
|
||||||
|
}
|
||||||
|
}".Replace("<group>", 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]
|
[Fact]
|
||||||
public void MigratingTestProjectAddsGenerateRuntimeConfigurationFiles()
|
public void MigratingTestProjectAddsGenerateRuntimeConfigurationFiles()
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,23 +178,23 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var contentItems = mockProj.Items.Where(item => item.ItemType == "None");
|
var contentItems = mockProj.Items.Where(item => item.ItemType == "None");
|
||||||
|
|
||||||
contentItems.Count().Should().Be(4);
|
contentItems.Count().Should().Be(3);
|
||||||
|
|
||||||
// 2 for Base Build options
|
// 2 for Base Build options
|
||||||
contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2);
|
contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2);
|
||||||
|
|
||||||
// 2 for Configuration BuildOptions (1 Remove, 1 Include)
|
// 2 for Configuration BuildOptions (1 Remove, 1 Update)
|
||||||
contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(2);
|
contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(1);
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Include));
|
item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Update));
|
||||||
var configRemoveContentItem = contentItems.First(
|
//var configRemoveContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove));
|
// 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
|
// Directories are not converted to globs in the result because we did not write the directory
|
||||||
configRemoveContentItem.Remove.Should().Be(@"root;src;rootfile.cs");
|
//configRemoveContentItem.Remove.Should().Be(@"root;src;rootfile.cs");
|
||||||
configIncludeContentItem.Include.Should().Be(@"root;src;rootfile.cs");
|
configIncludeContentItem.Update.Should().Be(@"root;rootfile.cs");
|
||||||
configIncludeContentItem.Exclude.Should().Be(@"src;root\rootfile.cs;src\file2.cs");
|
//configIncludeContentItem.Exclude.Should().Be(@"src;root\rootfile.cs;src\file2.cs");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -226,35 +226,46 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var contentItems = mockProj.Items.Where(item => item.ItemType == "None");
|
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
|
// 2 for Base Build options
|
||||||
contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2);
|
contentItems.Where(i => i.ConditionChain().Count() == 0).Should().HaveCount(2);
|
||||||
|
|
||||||
// 3 for Configuration BuildOptions (1 Remove, 2 Include)
|
// 3 for Configuration BuildOptions (1 Remove, 2 Update)
|
||||||
contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(3);
|
contentItems.Where(i => i.ConditionChain().Count() == 1).Should().HaveCount(1);
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include.Contains("root"));
|
&& item.Update.Contains("root"));
|
||||||
|
|
||||||
var configIncludeContentItem2 = contentItems.First(
|
var configIncludeContentItem2 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() == 0
|
||||||
&& item.Include.Contains(@"src\file1.cs"));
|
&& item.Update.Contains(@"src\file1.cs"));
|
||||||
|
|
||||||
var configRemoveContentItem = contentItems.First(
|
var configIncludeContentItem3 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0 && !string.IsNullOrEmpty(item.Remove));
|
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
|
// Directories are not converted to globs in the result because we did not write the directory
|
||||||
configRemoveContentItem.Removes()
|
//configRemoveContentItem.Removes()
|
||||||
.Should().BeEquivalentTo("root", "src", "rootfile.cs", @"src\file1.cs", @"src\file2.cs");
|
// .Should().BeEquivalentTo("root", "src", "rootfile.cs", @"src\file1.cs", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem.Includes().Should().BeEquivalentTo("root", "src", "rootfile.cs");
|
configIncludeContentItem.Updates().Should().BeEquivalentTo("root", "rootfile.cs");
|
||||||
configIncludeContentItem.Excludes()
|
//configIncludeContentItem.Excludes()
|
||||||
.Should().BeEquivalentTo("rootfile.cs", "someotherfile.cs", @"src\file2.cs");
|
// .Should().BeEquivalentTo("rootfile.cs", "someotherfile.cs", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs");
|
configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs");
|
||||||
configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs");
|
//configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs");
|
||||||
|
|
||||||
|
configIncludeContentItem3.Updates().Should().BeEquivalentTo(@"src");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -287,15 +298,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include.Contains("root"));
|
&& item.Update.Contains("root"));
|
||||||
|
|
||||||
var configIncludeContentItem2 = contentItems.First(
|
var configIncludeContentItem2 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include.Contains(@"src\file1.cs"));
|
&& item.Update.Contains(@"src\file1.cs"));
|
||||||
|
|
||||||
configIncludeContentItem.Includes().Should().BeEquivalentTo("root", "src");
|
configIncludeContentItem.Updates().Should().BeEquivalentTo("root", "src");
|
||||||
configIncludeContentItem.Excludes()
|
// configIncludeContentItem.Excludes()
|
||||||
.Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs");
|
// .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
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").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
||||||
|
|
||||||
configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs");
|
configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file1.cs", @"src\file2.cs");
|
||||||
configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs");
|
// configIncludeContentItem2.Excludes().Should().BeEquivalentTo(@"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull();
|
configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull();
|
||||||
configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
||||||
|
@ -345,36 +356,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include == "root");
|
&& item.Update == "root");
|
||||||
|
|
||||||
var configIncludeContentItem2 = contentItems.First(
|
var configIncludeContentItem2 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include == "src");
|
&& item.Update == "src");
|
||||||
|
|
||||||
var configIncludeContentItem3 = contentItems.First(
|
var configIncludeContentItem3 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
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
|
// Directories are not converted to globs in the result because we did not write the directory
|
||||||
|
|
||||||
configIncludeContentItem.Includes().Should().BeEquivalentTo("root");
|
configIncludeContentItem.Updates().Should().BeEquivalentTo("root");
|
||||||
configIncludeContentItem.Excludes()
|
// configIncludeContentItem.Excludes()
|
||||||
.Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs");
|
// .Should().BeEquivalentTo("rootfile.cs", "src", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Should().BeNull();
|
configIncludeContentItem.GetMetadataWithName("Link").Should().BeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
||||||
|
|
||||||
configIncludeContentItem2.Include.Should().Be("src");
|
configIncludeContentItem2.Update.Should().Be("src");
|
||||||
configIncludeContentItem2.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs");
|
// configIncludeContentItem2.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull();
|
configIncludeContentItem2.GetMetadataWithName("Link").Should().NotBeNull();
|
||||||
configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
configIncludeContentItem2.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
||||||
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
||||||
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
||||||
|
|
||||||
configIncludeContentItem3.Includes().Should().BeEquivalentTo(@"src\file1.cs");
|
configIncludeContentItem3.Updates().Should().BeEquivalentTo(@"src\file1.cs");
|
||||||
configIncludeContentItem3.Exclude.Should().Be(@"src\file2.cs");
|
// configIncludeContentItem3.Exclude.Should().Be(@"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem3.GetMetadataWithName("Link").Should().BeNull();
|
configIncludeContentItem3.GetMetadataWithName("Link").Should().BeNull();
|
||||||
configIncludeContentItem3.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
configIncludeContentItem3.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
||||||
|
@ -427,13 +438,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include.Contains("src"));
|
&& item.Update.Contains("src"));
|
||||||
|
|
||||||
var configRemoveContentItem = contentItems.First(
|
var configRemoveContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& !string.IsNullOrEmpty(item.Remove));
|
&& !string.IsNullOrEmpty(item.Remove));
|
||||||
|
|
||||||
configIncludeContentItem.Include.Should().Be("src");
|
configIncludeContentItem.Update.Should().Be("src");
|
||||||
|
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
||||||
|
@ -492,31 +503,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
var configIncludeEncompassedItem = contentItems.FirstOrDefault(
|
var configIncludeEncompassedItem = contentItems.FirstOrDefault(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include == "root");
|
&& item.Update == "root");
|
||||||
configIncludeEncompassedItem.Should().BeNull();
|
configIncludeEncompassedItem.Should().BeNull();
|
||||||
|
|
||||||
var configIncludeContentItem = contentItems.First(
|
var configIncludeContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include == "src");
|
&& item.Update == "src");
|
||||||
|
|
||||||
var configIncludeContentItem2 = contentItems.First(
|
var configIncludeContentItem2 = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& item.Include.Contains(@"src\file3.cs"));
|
&& item.Update.Contains(@"src\file3.cs"));
|
||||||
|
|
||||||
var configRemoveContentItem = contentItems.First(
|
var configRemoveContentItem = contentItems.First(
|
||||||
item => item.ConditionChain().Count() > 0
|
item => item.ConditionChain().Count() > 0
|
||||||
&& !string.IsNullOrEmpty(item.Remove));
|
&& !string.IsNullOrEmpty(item.Remove));
|
||||||
|
|
||||||
configIncludeContentItem.Include.Should().Be("src");
|
configIncludeContentItem.Update.Should().Be("src");
|
||||||
configIncludeContentItem.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs");
|
//configIncludeContentItem.Excludes().Should().BeEquivalentTo("src", "rootfile.cs", @"src\rootfile.cs", @"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
configIncludeContentItem.GetMetadataWithName("Link").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
configIncludeContentItem.GetMetadataWithName("Link").Value.Should().Be("/some/dir/%(FileName)%(Extension)");
|
||||||
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
||||||
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
configIncludeContentItem.GetMetadataWithName("CopyToOutputDirectory").Value.Should().Be("PreserveNewest");
|
||||||
|
|
||||||
configIncludeContentItem2.Includes().Should().BeEquivalentTo(@"src\file3.cs");
|
configIncludeContentItem2.Updates().Should().BeEquivalentTo(@"src\file3.cs");
|
||||||
configIncludeContentItem2.Exclude.Should().Be(@"src\file2.cs");
|
//configIncludeContentItem2.Exclude.Should().Be(@"src\file2.cs");
|
||||||
|
|
||||||
configIncludeContentItem2.GetMetadataWithName("Link").Should().BeNull();
|
configIncludeContentItem2.GetMetadataWithName("Link").Should().BeNull();
|
||||||
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
configIncludeContentItem2.GetMetadataWithName("CopyToOutputDirectory").Should().NotBeNull();
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
.Where(item => item.GetMetadataWithName("Pack").Value == "true");
|
.Where(item => item.GetMetadataWithName("Pack").Value == "true");
|
||||||
|
|
||||||
contentItems.Count().Should().Be(1);
|
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]
|
[Fact]
|
||||||
|
@ -229,7 +229,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
item.GetMetadataWithName("PackagePath") != null);
|
item.GetMetadataWithName("PackagePath") != null);
|
||||||
|
|
||||||
contentItems.Count().Should().Be(1);
|
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(
|
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(
|
||||||
Path.Combine("some", "other", "path"));
|
Path.Combine("some", "other", "path"));
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
item.GetMetadataWithName("PackagePath") != null);
|
item.GetMetadataWithName("PackagePath") != null);
|
||||||
|
|
||||||
contentItems.Count().Should().Be(1);
|
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();
|
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
item.GetMetadataWithName("PackagePath") != null);
|
item.GetMetadataWithName("PackagePath") != null);
|
||||||
|
|
||||||
contentItems.Count().Should().Be(1);
|
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);
|
contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(expectedPackagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,18 +38,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
{
|
{
|
||||||
item.Metadata.Count(m => m.Name == "CopyToPublishDirectory").Should().Be(1);
|
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.Update.Should().Be(@"src\file1.cs;src\file2.cs");
|
||||||
item.Exclude.Should().Be(@"src\file2.cs");
|
item.Exclude.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.Include.Should()
|
item.Update.Should().Be(@"root\**\*;src\**\*;rootfile.cs");
|
||||||
.Be(@"root\**\*;src\**\*;rootfile.cs");
|
item.Exclude.Should().BeEmpty();
|
||||||
|
|
||||||
item.Exclude.Should()
|
|
||||||
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,29 +125,25 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
mockProj.Items.Count(i => i.ItemType.Equals("None", StringComparison.Ordinal)).Should().Be(3);
|
mockProj.Items.Count(i => i.ItemType.Equals("None", StringComparison.Ordinal)).Should().Be(3);
|
||||||
|
|
||||||
// From ProjectReader #L725 (Both are empty)
|
|
||||||
var defaultIncludePatterns = Enumerable.Empty<string>();
|
|
||||||
var defaultExcludePatterns = Enumerable.Empty<string>();
|
|
||||||
|
|
||||||
foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals("None", StringComparison.Ordinal)))
|
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.Update.Should().Be(@"root\**\*");
|
||||||
item.Exclude.Should().Be(@"src\**\*;rootfile.cs;src\file3.cs");
|
//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.Update.Should().Be(@"src\file1.cs;src\file2.cs");
|
||||||
item.Exclude.Should().Be(@"src\file2.cs;src\file3.cs");
|
//item.Exclude.Should().Be(@"src\file2.cs;src\file3.cs");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.Include.Should()
|
item.Update.Should()
|
||||||
.Be(@"src\**\*;rootfile.cs");
|
.Be(@"src\**\*;rootfile.cs");
|
||||||
|
|
||||||
item.Exclude.Should()
|
//item.Exclude.Should()
|
||||||
.Be(@"src\**\*;rootfile.cs;src\file2.cs;src\file3.cs");
|
// .Be(@"src\**\*;rootfile.cs;src\file2.cs;src\file3.cs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue