@joebigelow / wix / commits / 214f53de

Fix overridable actions being tagged as duplicates.

Bob Arnson committed Jan 16, 2019 at 16:25 UTC 214f53de1c6500aa8dd46e9604c90178807fda1a
9 files changed +165 -10
src/WixToolset.Core.TestPackage/WixRunnerResult.cs
+21 -3
@@ -1,9 +1,9 @@
1 -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Core.TestPackage
4 {
5 using System;
6 - using System.Linq;
6 + using System.Collections.Generic;
7 using WixToolset.Data;
8 using Xunit;
9
@@ -15,8 +15,26 @@ namespace WixToolset.Core.TestPackage
15
16 public WixRunnerResult AssertSuccess()
17 {
18 - Assert.True(0 == this.ExitCode, $"\r\n\r\nWixRunner failed with exit code: {this.ExitCode}\r\n Output: {String.Join("\r\n ", this.Messages.Select(m => m.ToString()).ToArray())}\r\n");
18 + Assert.True(0 == this.ExitCode, $"\r\n\r\nWixRunner failed with exit code: {this.ExitCode}\r\n Output: {String.Join("\r\n ", FormatMessages(this.Messages))}\r\n");
19 return this;
20 }
21 +
22 + private static IEnumerable<string> FormatMessages(IEnumerable<Message> messages)
23 + {
24 + foreach (var message in messages)
25 + {
26 + var filename = message.SourceLineNumbers?.FileName ?? "TEST";
27 + var line = message.SourceLineNumbers?.LineNumber ?? -1;
28 + var type = message.Level.ToString().ToLowerInvariant();
29 + var output = message.Level >= MessageLevel.Warning ? Console.Out : Console.Error;
30 +
31 + if (line > 0)
32 + {
33 + filename = String.Concat(filename, "(", line, ")");
34 + }
35 +
36 + yield return String.Format("{0} : {1} {2}{3:0000}: {4}", filename, type, "TEST", message.Id, message.ToString());
37 + }
38 + }
39 }
40 }
src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+1 -1
@@ -92,7 +92,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
92 }
93 }
94
95 - if (overridableActionRows.TryGetValue(actionRow.Id.Id, out var collidingActionRow))
95 + if (requiredActionRows.TryGetValue(actionRow.Id.Id, out var collidingActionRow))
96 {
97 this.Messaging.Write(ErrorMessages.ActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action));
98 if (null != collidingActionRow.SourceLineNumbers)
src/WixToolset.Core/Link/ResolveReferencesCommand.cs
+14 -6
@@ -66,7 +66,7 @@ namespace WixToolset.Core.Link
66 {
67 // If we're building a Merge Module, ignore all references to the Media table
68 // because Merge Modules don't have Media tables.
69 - if (this.BuildingMergeModule && wixSimpleReferenceRow.Table== "Media")
69 + if (this.BuildingMergeModule && wixSimpleReferenceRow.Table == "Media")
70 {
71 continue;
72 }
@@ -77,7 +77,7 @@ namespace WixToolset.Core.Link
77 }
78 else // see if the symbol (and any of its duplicates) are appropriately accessible.
79 {
80 - IList<Symbol> accessible = DetermineAccessibleSymbols(section, symbol);
80 + IList<Symbol> accessible = this.DetermineAccessibleSymbols(section, symbol);
81 if (!accessible.Any())
82 {
83 this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access));
@@ -89,7 +89,7 @@ namespace WixToolset.Core.Link
89
90 if (null != accessibleSymbol.Section)
91 {
92 - RecursivelyResolveReferences(accessibleSymbol.Section);
92 + this.RecursivelyResolveReferences(accessibleSymbol.Section);
93 }
94 }
95 else // display errors for the duplicate symbols.
@@ -125,14 +125,22 @@ namespace WixToolset.Core.Link
125 {
126 List<Symbol> symbols = new List<Symbol>();
127
128 - if (AccessibleSymbol(referencingSection, symbol))
128 + if (this.AccessibleSymbol(referencingSection, symbol))
129 {
130 symbols.Add(symbol);
131 }
132
133 foreach (Symbol dupe in symbol.PossiblyConflictingSymbols)
134 {
135 - if (AccessibleSymbol(referencingSection, dupe))
135 + // don't count overridable WixActionTuples
136 + WixActionTuple symbolAction = symbol.Row as WixActionTuple;
137 + WixActionTuple dupeAction = dupe.Row as WixActionTuple;
138 + if (symbolAction?.Overridable != dupeAction?.Overridable)
139 + {
140 + continue;
141 + }
142 +
143 + if (this.AccessibleSymbol(referencingSection, dupe))
144 {
145 symbols.Add(dupe);
146 }
@@ -140,7 +148,7 @@ namespace WixToolset.Core.Link
148
149 foreach (Symbol dupe in symbol.RedundantSymbols)
150 {
143 - if (AccessibleSymbol(referencingSection, dupe))
151 + if (this.AccessibleSymbol(referencingSection, dupe))
152 {
153 symbols.Add(dupe);
154 }
src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs new
+54
@@ -0,0 +1,54 @@
1 +
2 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3 +
4 +namespace WixToolsetTest.CoreIntegration
5 +{
6 + using System.IO;
7 + using System.Linq;
8 + using WixBuildTools.TestSupport;
9 + using WixToolset.Core.TestPackage;
10 + using WixToolset.Data;
11 + using WixToolset.Data.Tuples;
12 + using WixToolset.Data.WindowsInstaller;
13 + using Xunit;
14 +
15 + public class LinkerFixture
16 + {
17 + [Fact]
18 + public void CanBuildWithOverridableActions()
19 + {
20 + var folder = TestData.Get(@"TestData\OverridableActions");
21 +
22 + using (var fs = new DisposableFileSystem())
23 + {
24 + var baseFolder = fs.GetFolder();
25 + var intermediateFolder = Path.Combine(baseFolder, "obj");
26 +
27 + var result = WixRunner.Execute(new[]
28 + {
29 + "build",
30 + Path.Combine(folder, "Package.wxs"),
31 + Path.Combine(folder, "PackageComponents.wxs"),
32 + "-loc", Path.Combine(folder, "Package.en-us.wxl"),
33 + "-bindpath", Path.Combine(folder, "data"),
34 + "-intermediateFolder", intermediateFolder,
35 + "-o", Path.Combine(baseFolder, @"bin\test.msi")
36 + });
37 +
38 + result.AssertSuccess();
39 +
40 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
41 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));
42 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\MsiPackage\test.txt")));
43 +
44 + var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir"));
45 + var section = intermediate.Sections.Single();
46 +
47 + var actions = section.Tuples.OfType<WixActionTuple>().Where(wat => wat.Action.StartsWith("Set")).ToList();
48 + Assert.Equal(2, actions.Count);
49 + //Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
50 + //Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
51 + }
52 + }
53 + }
54 +}
src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.en-us.wxl new
+11
@@ -0,0 +1,11 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<!--
4 +This file contains the declaration of all the localizable strings.
5 +-->
6 +<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7 +
8 + <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 + <String Id="FeatureTitle">MsiPackage</String>
10 +
11 +</WixLocalization>
src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.wxs new
+49
@@ -0,0 +1,49 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
4 + <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
5 + <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
6 +
7 + <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
8 + <MediaTemplate />
9 +
10 + <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
11 + <ComponentGroupRef Id="ProductComponents" />
12 + <ComponentGroupRef Id="Foo1" />
13 + <ComponentGroupRef Id="Foo2" />
14 + </Feature>
15 +
16 + <!--<CustomActionRef Id="SetFoo" />-->
17 +
18 + </Product>
19 +
20 + <Fragment Id="SetFoo">
21 + <CustomAction Id="SetFoo" Property="FOO" Value="BOB" />
22 + <CustomAction Id="SetBar" Property="BAR" Value="BOB" />
23 + </Fragment>
24 +
25 + <Fragment Id="Foo1">
26 + <ComponentGroup Id="Foo1" />
27 +
28 + <InstallExecuteSequence>
29 + <Custom Action="SetFoo" Before="SetBar" />
30 + <Custom Action="SetBar" Overridable="yes" Before="AppSearch" />
31 + </InstallExecuteSequence>
32 + </Fragment>
33 +
34 + <Fragment Id="Foo2">
35 + <ComponentGroup Id="Foo2" />
36 +
37 + <InstallExecuteSequence>
38 + <Custom Action="SetBar" Before="AppSearch" />
39 + </InstallExecuteSequence>
40 + </Fragment>
41 +
42 + <Fragment Id="Directories">
43 + <Directory Id="TARGETDIR" Name="SourceDir">
44 + <Directory Id="ProgramFilesFolder">
45 + <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
46 + </Directory>
47 + </Directory>
48 + </Fragment>
49 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/PackageComponents.wxs new
+10
@@ -0,0 +1,10 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5 + <Component>
6 + <File Source="test.txt" />
7 + </Component>
8 + </ComponentGroup>
9 + </Fragment>
10 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/data/test.txt new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+4
@@ -77,6 +77,10 @@
77 <Content Include="TestData\Variables\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
78 <Content Include="TestData\Variables\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
79 <Content Include="TestData\Variables\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
80 + <Content Include="TestData\OverridableActions\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
81 + <Content Include="TestData\OverridableActions\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
82 + <Content Include="TestData\OverridableActions\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
83 + <Content Include="TestData\OverridableActions\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
84 </ItemGroup>
85
86 <ItemGroup>