[Fixes #3856] Allow mapping of the same file to multiple target paths

This commit is contained in:
Ajay Bhargav Baaskaran 2016-07-13 14:56:22 -07:00
parent 69eed12132
commit c748c81a4a
3 changed files with 4 additions and 2 deletions

View file

@ -20,7 +20,8 @@
"files": {
"includeFiles": "packfiles/pack1.txt",
"mappings": {
"newpath/": "packfiles/pack2.txt"
"newpath/": "packfiles/pack2.txt",
"anotherpath/": "packfiles/pack2.txt"
}
}
},

View file

@ -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);
}
}

View file

@ -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]