diff --git a/history/5227.md b/history/5227.md new file mode 100644 index 00000000..dda5caab --- /dev/null +++ b/history/5227.md @@ -0,0 +1 @@ +* HeathS: WIXBUG:5227 - Allow for merging of directories from different wixlibs and sources diff --git a/src/tools/light/LightStrings.Designer.cs b/src/tools/light/LightStrings.Designer.cs index bf470b18..d1a0aaef 100644 --- a/src/tools/light/LightStrings.Designer.cs +++ b/src/tools/light/LightStrings.Designer.cs @@ -62,6 +62,7 @@ namespace Microsoft.Tools.WindowsInstallerXml.Tools { /// /// Looks up a localized string similar to -ai allow identical rows, identical rows will be treated as a warning + /// -ad allow duplicate directory identities from other libraries /// -au (experimental) allow unresolved references /// (will not create a valid output) /// -b <path> specify a base path to locate all files diff --git a/src/tools/light/LightStrings.resx b/src/tools/light/LightStrings.resx index 3b2bbd3c..9e0b01ac 100644 --- a/src/tools/light/LightStrings.resx +++ b/src/tools/light/LightStrings.resx @@ -119,6 +119,7 @@ -ai allow identical rows, identical rows will be treated as a warning + -ad allow duplicate directory identities from other libraries -au (experimental) allow unresolved references (will not create a valid output) -b <path> specify a binder path to locate all files diff --git a/src/tools/light/light.cs b/src/tools/light/light.cs index 1fee901b..c5b375d9 100644 --- a/src/tools/light/light.cs +++ b/src/tools/light/light.cs @@ -35,6 +35,7 @@ namespace Microsoft.Tools.WindowsInstallerXml.Tools { private string[] cultures; private bool allowIdenticalRows; + private bool allowDuplicateDirectoryIds; private bool allowUnresolvedReferences; private bool bindFiles; private WixBinder binder; @@ -211,6 +212,7 @@ namespace Microsoft.Tools.WindowsInstallerXml.Tools } linker.AllowIdenticalRows = this.allowIdenticalRows; + linker.AllowDuplicateDirectoryIds = this.allowDuplicateDirectoryIds; linker.AllowUnresolvedReferences = this.allowUnresolvedReferences; linker.Cultures = this.cultures; linker.UnreferencedSymbolsFile = this.unreferencedSymbolsFile; @@ -518,6 +520,10 @@ namespace Microsoft.Tools.WindowsInstallerXml.Tools this.messageHandler.Display(this, WixWarnings.DeprecatedCommandLineSwitch("ai")); this.allowIdenticalRows = true; } + else if (parameter.Equals("ad", StringComparison.Ordinal)) + { + this.allowDuplicateDirectoryIds = true; + } else if (parameter.Equals("au", StringComparison.Ordinal)) { this.messageHandler.Display(this, WixWarnings.DeprecatedCommandLineSwitch("au")); diff --git a/src/tools/wix/Librarian.cs b/src/tools/wix/Librarian.cs index 5fbf599a..9583003e 100644 --- a/src/tools/wix/Librarian.cs +++ b/src/tools/wix/Librarian.cs @@ -134,7 +134,7 @@ namespace Microsoft.Tools.WindowsInstallerXml Section entrySection; SymbolCollection allSymbols; - library.Sections.FindEntrySectionAndLoadSymbols(false, this, OutputType.Unknown, out entrySection, out allSymbols); + library.Sections.FindEntrySectionAndLoadSymbols(false, this, OutputType.Unknown, false, out entrySection, out allSymbols); foreach (Section section in library.Sections) { diff --git a/src/tools/wix/Linker.cs b/src/tools/wix/Linker.cs index 8ff73b7d..bf1e74a9 100644 --- a/src/tools/wix/Linker.cs +++ b/src/tools/wix/Linker.cs @@ -37,6 +37,7 @@ namespace Microsoft.Tools.WindowsInstallerXml private bool dropUnrealTables; private bool encounteredError; private bool allowIdenticalRows; + private bool allowDuplicateDirectoryIds; private bool allowUnresolvedReferences; private ArrayList extensions; private List inspectorExtensions; @@ -103,6 +104,16 @@ namespace Microsoft.Tools.WindowsInstallerXml set { this.allowIdenticalRows = value; } } + /// + /// Gets or sets whether to allow duplicate directory IDs. + /// + /// Whether to allow duplicate directory IDs. + public bool AllowDuplicateDirectoryIds + { + get { return this.allowDuplicateDirectoryIds; } + set { this.allowDuplicateDirectoryIds = value; } + } + /// /// Gets or sets the flag specifying if unresolved references are allowed during linking. /// @@ -361,7 +372,7 @@ namespace Microsoft.Tools.WindowsInstallerXml } // first find the entry section and create the symbols hash for all the sections - sections.FindEntrySectionAndLoadSymbols(this.allowIdenticalRows, this, expectedOutputType, out entrySection, out allSymbols); + sections.FindEntrySectionAndLoadSymbols(this.allowIdenticalRows, this, expectedOutputType, this.allowDuplicateDirectoryIds, out entrySection, out allSymbols); // should have found an entry section by now if (null == entrySection) diff --git a/src/tools/wix/SectionCollection.cs b/src/tools/wix/SectionCollection.cs index 815fe28d..a67bbb48 100644 --- a/src/tools/wix/SectionCollection.cs +++ b/src/tools/wix/SectionCollection.cs @@ -200,12 +200,14 @@ namespace Microsoft.Tools.WindowsInstallerXml /// Flag specifying whether identical rows are allowed or not. /// Message handler object to route all errors through. /// Expected entry output type, based on output file extension provided to the linker. + /// Allow duplicate directory IDs instead of erring. /// Located entry section. /// Collection of symbols loaded. internal void FindEntrySectionAndLoadSymbols( bool allowIdenticalRows, IMessageHandler messageHandler, OutputType expectedOutputType, + bool allowDuplicateDirectoryIds, out Section entrySection, out SymbolCollection allSymbols) { @@ -259,7 +261,11 @@ namespace Microsoft.Tools.WindowsInstallerXml } else { - allSymbols.AddDuplicate(symbol); + // Allow linking wixlibs with the same directory definitions. + if (!allowDuplicateDirectoryIds || symbol.Row.TableDefinition.Name != "Directory") + { + allSymbols.AddDuplicate(symbol); + } } } catch (DuplicateSymbolsException) diff --git a/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/Package.wxs b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/Package.wxs new file mode 100644 index 00000000..e837b170 --- /dev/null +++ b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/Package.wxs @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectOne.wxs b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectOne.wxs new file mode 100644 index 00000000..4e748b1a --- /dev/null +++ b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectOne.wxs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectTwo.wxs b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectTwo.wxs new file mode 100644 index 00000000..34a71aa3 --- /dev/null +++ b/test/data/Tools/Light/Input/WixlibTests/MultipleWixlibsWithDirs/ProjectTwo.wxs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/src/WixTestTools/Verifiers/Verifier.cs b/test/src/WixTestTools/Verifiers/Verifier.cs index f3445008..47eb4fc2 100644 --- a/test/src/WixTestTools/Verifiers/Verifier.cs +++ b/test/src/WixTestTools/Verifiers/Verifier.cs @@ -911,6 +911,7 @@ namespace WixTest switch ((string)row[0]) { case "ProductCode": + case "WixPdbPath": return true; } } diff --git a/test/src/WixTests/Tools/Light/Input.WixlibTests.cs b/test/src/WixTests/Tools/Light/Input.WixlibTests.cs index ed838d13..77403160 100644 --- a/test/src/WixTests/Tools/Light/Input.WixlibTests.cs +++ b/test/src/WixTests/Tools/Light/Input.WixlibTests.cs @@ -106,5 +106,52 @@ namespace WixTest.Tests.Tools.Light.Input Verifier.VerifyResults(expectedMSI, light2.OutputFile); } + [NamedFact] + [Description("Verify that Light can link multiple wixlibs with same directories")] + [Priority(2)] + public void MultipleWixlibsWithSameDirectories() + { + // Create Temp Directory + string outputDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Utilities.FileUtilities.CreateOutputDirectory(outputDirectory); + + string testDir = Path.Combine(WixlibTests.TestDataDirectory, "MultipleWixlibsWithDirs"); + + // Build the package + Candle candle1 = new Candle(); + candle1.SourceFiles.Add(Path.Combine(testDir, "Package.wxs")); + candle1.OutputFile = Path.Combine(outputDirectory, "Package.wixobj"); + candle1.Run(); + + // Build the first wixlib + Candle candle2 = new Candle(); + candle2.SourceFiles.Add(Path.Combine(testDir, "ProjectOne.wxs")); + candle2.OutputFile = Path.Combine(outputDirectory, "ProjectOne.wixobj"); + candle2.Run(); + + Lit lit2 = new Lit(candle2); + lit2.OutputFile = Path.Combine(outputDirectory, "ProjectOne.wixlib"); + lit2.Run(); + + // Build the second wixlib + Candle candle3 = new Candle(); + candle3.SourceFiles.Add(Path.Combine(testDir, "ProjectTwo.wxs")); + candle3.OutputFile = Path.Combine(outputDirectory, "ProjectTwo.wixobj"); + candle3.Run(); + + Lit lit3 = new Lit(candle3); + lit3.OutputFile = Path.Combine(outputDirectory, "ProjectTwo.wixlib"); + lit3.Run(); + + // Link everything together - will have duplicate directories + Light light = new Light(); + light.ObjectFiles.Add(candle1.OutputFile); + light.ObjectFiles.Add(lit2.OutputFile); + light.ObjectFiles.Add(lit3.OutputFile); + light.OutputFile = Path.Combine(outputDirectory, "actual.msi"); + light.Run("-ad"); + + // Verifier.VerifyResults(Path.Combine(testDir, "expected.msi"), light.OutputFile); + } } }