From c748c81a4a312751e363ecc58de77acbbdfa63b3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 14:56:22 -0700 Subject: [PATCH 1/3] [Fixes #3856] Allow mapping of the same file to multiple target paths --- TestAssets/TestProjects/EndToEndTestApp/project.json | 3 ++- .../Files/IncludeFilesResolver.cs | 2 +- test/dotnet-pack.Tests/PackTests.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TestAssets/TestProjects/EndToEndTestApp/project.json b/TestAssets/TestProjects/EndToEndTestApp/project.json index a83d47689..dc84f6625 100644 --- a/TestAssets/TestProjects/EndToEndTestApp/project.json +++ b/TestAssets/TestProjects/EndToEndTestApp/project.json @@ -20,7 +20,8 @@ "files": { "includeFiles": "packfiles/pack1.txt", "mappings": { - "newpath/": "packfiles/pack2.txt" + "newpath/": "packfiles/pack2.txt", + "anotherpath/": "packfiles/pack2.txt" } } }, diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs index 15ff88670..a52ffb620 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs @@ -150,7 +150,7 @@ namespace Microsoft.DotNet.ProjectModel.Files file.IsCustomTarget = true; // Prefer named targets over default ones - includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath)); + includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath) && f.IsCustomTarget == false); includeEntries.Add(file); } } diff --git a/test/dotnet-pack.Tests/PackTests.cs b/test/dotnet-pack.Tests/PackTests.cs index 5091e7fd7..1d9f7500a 100644 --- a/test/dotnet-pack.Tests/PackTests.cs +++ b/test/dotnet-pack.Tests/PackTests.cs @@ -113,6 +113,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read); zip.Entries.Should().Contain(e => e.FullName == "packfiles/pack1.txt"); zip.Entries.Should().Contain(e => e.FullName == "newpath/pack2.txt"); + zip.Entries.Should().Contain(e => e.FullName == "anotherpath/pack2.txt"); } [Fact] From dbf7435c3ca7f1e97652c6291ac0cc5770a3b307 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 15:09:22 -0700 Subject: [PATCH 2/3] [Fixes #3502] Fix: publishOptions: [...] not respected --- TestAssets/TestProjects/EndToEndTestApp/project.json | 2 +- .../EndToEndTestApp/publishfiles/anotherpublishfile.txt | 0 src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs | 3 ++- test/dotnet-publish.Tests/PublishTests.cs | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt diff --git a/TestAssets/TestProjects/EndToEndTestApp/project.json b/TestAssets/TestProjects/EndToEndTestApp/project.json index dc84f6625..10ae17942 100644 --- a/TestAssets/TestProjects/EndToEndTestApp/project.json +++ b/TestAssets/TestProjects/EndToEndTestApp/project.json @@ -25,7 +25,7 @@ } } }, - "publishOptions": "testpublishfile.txt", + "publishOptions": [ "testpublishfile.txt", "publishfiles" ], "frameworks": { "netcoreapp1.0": {} }, diff --git a/TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt b/TestAssets/TestProjects/EndToEndTestApp/publishfiles/anotherpublishfile.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs index 39661bf1d..ebedcdad3 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeContext.cs @@ -40,7 +40,8 @@ namespace Microsoft.DotNet.ProjectModel.Files var token = rawObject.Value(option); if (token.Type != JTokenType.Object) { - IncludePatterns = new List(ExtractValues(token)); + IncludePatterns = CreateCollection( + sourceBasePath, option, ExtractValues(token), literalPath: false); } else { diff --git a/test/dotnet-publish.Tests/PublishTests.cs b/test/dotnet-publish.Tests/PublishTests.cs index 924bad75b..19084e855 100644 --- a/test/dotnet-publish.Tests/PublishTests.cs +++ b/test/dotnet-publish.Tests/PublishTests.cs @@ -128,6 +128,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("testpublishfile.txt"); + publishCommand.GetOutputDirectory().Should().HaveFile("publishfiles/anotherpublishfile.txt"); } [Fact] From 01021a0a6d4701ca12e831fda823fda8cacc9bf3 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 13 Jul 2016 15:52:23 -0700 Subject: [PATCH 3/3] Addressed feedback --- src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs index a52ffb620..f1baeb70f 100644 --- a/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs +++ b/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs @@ -150,7 +150,7 @@ namespace Microsoft.DotNet.ProjectModel.Files file.IsCustomTarget = true; // Prefer named targets over default ones - includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath) && f.IsCustomTarget == false); + includeEntries.RemoveWhere(f => string.Equals(f.SourcePath, file.SourcePath) && !f.IsCustomTarget); includeEntries.Add(file); } }