Optionally allow duplicate directory identifiers

Resolves wixtoolset/issues#5227 to allow merging wixlibs from swix into
products linked using traditional wix.
This commit is contained in:
Heath Stewart 2016-02-26 16:39:19 -08:00 коммит произвёл Bob Arnson
Родитель 96d6a3a172
Коммит ec7cdfd563
12 изменённых файлов: 156 добавлений и 3 удалений

1
history/5227.md Normal file
Просмотреть файл

@ -0,0 +1 @@
* HeathS: WIXBUG:5227 - Allow for merging of directories from different wixlibs and sources

1
src/tools/light/LightStrings.Designer.cs сгенерированный
Просмотреть файл

@ -62,6 +62,7 @@ namespace Microsoft.Tools.WindowsInstallerXml.Tools {
/// <summary>
/// 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 &lt;path&gt; specify a base path to locate all files

Просмотреть файл

@ -119,6 +119,7 @@
</resheader>
<data name="CommandLineArguments" xml:space="preserve">
<value> -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 &lt;path&gt; specify a binder path to locate all files

Просмотреть файл

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

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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<InspectorExtension> inspectorExtensions;
@ -103,6 +104,16 @@ namespace Microsoft.Tools.WindowsInstallerXml
set { this.allowIdenticalRows = value; }
}
/// <summary>
/// Gets or sets whether to allow duplicate directory IDs.
/// </summary>
/// <value>Whether to allow duplicate directory IDs.</value>
public bool AllowDuplicateDirectoryIds
{
get { return this.allowDuplicateDirectoryIds; }
set { this.allowDuplicateDirectoryIds = value; }
}
/// <summary>
/// Gets or sets the flag specifying if unresolved references are allowed during linking.
/// </summary>
@ -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)

Просмотреть файл

@ -200,12 +200,14 @@ namespace Microsoft.Tools.WindowsInstallerXml
/// <param name="allowIdenticalRows">Flag specifying whether identical rows are allowed or not.</param>
/// <param name="messageHandler">Message handler object to route all errors through.</param>
/// <param name="expectedOutputType">Expected entry output type, based on output file extension provided to the linker.</param>
/// <param name="allowDuplicateDirectoryIds">Allow duplicate directory IDs instead of erring.</param>
/// <param name="entrySection">Located entry section.</param>
/// <param name="allSymbols">Collection of symbols loaded.</param>
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)

Просмотреть файл

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
<copyright file="Package.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="0fa028f1-3c9e-40e0-bd29-71f7b419b63e" Name="MultipleSwrProjs" Language="1033" Version="1.1.2.3" Manufacturer="Microsoft Corporation" UpgradeCode="{e8b0f42b-2c73-47de-ac79-6c978b66e261}">
<Package InstallScope="perMachine" Description="Test building against multiple swix" InstallerVersion="200" Compressed="yes" />
<MediaTemplate EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir" />
<DirectoryRef Id="TARGETDIR">
<Directory Id="ProgramFilesFolder" Name="Program Files" />
</DirectoryRef>
<Feature Id="Test" Title="Test" Level="1">
<ComponentGroupRef Id="ProjectOneGroup" />
<ComponentGroupRef Id="ProjectTwoGroup" />
</Feature>
</Product>
</Wix>

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<copyright file="ProjectOne.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment Id="ProjectOneDirSection">
<DirectoryRef Id="ProgramFilesFolder">
<Directory Id="Foo" Name="Foo">
<Directory Id="Bar" Name="Bar" />
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProjectOneGroup">
<ComponentRef Id="ProjectOne" />
</ComponentGroup>
<DirectoryRef Id="Bar">
<Component Id="ProjectOne">
<File Id="ProjectOne" Name="ProjectOne.wxs" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<copyright file="ProjectTwo.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment Id="ProjectTwoDirSection">
<DirectoryRef Id="ProgramFilesFolder">
<Directory Id="Foo" Name="Foo">
<Directory Id="Bar" Name="Bar" />
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProjectTwoGroup">
<ComponentRef Id="ProjectTwo" />
</ComponentGroup>
<DirectoryRef Id="Bar">
<Component Id="ProjectTwo">
<File Id="ProjectTwo" Name="ProjectTwo.wxs" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>

Просмотреть файл

@ -911,6 +911,7 @@ namespace WixTest
switch ((string)row[0])
{
case "ProductCode":
case "WixPdbPath":
return true;
}
}

Просмотреть файл

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