@joebigelow / wix / commits / eb2f85d7

Improve error when virtual action symbols collide.

Bob Arnson committed Feb 3, 2024 at 22:52 UTC eb2f85d7ee5ad5c91af0943ffe936ee8ccfdab0d
3 files changed +25 -6
src/ext/Util/test/WixToolsetTest.Util/TestData/CloseApplication/Package.wxs
+9 -5
@@ -1,4 +1,4 @@
1 -<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
4
@@ -7,11 +7,15 @@
7 </Feature>
8
9 <util:CloseApplication Id="CloseMyApp" CloseMessage="yes" Property="MYAPPISRUNNING" Target="explorer.exe" />
10 +
11 + <InstallExecuteSequence>
12 + <Custom Action="override Wix4CloseApplications_$(sys.BUILDARCHSHORT)" After="InstallInitialize" />
13 + </InstallExecuteSequence>
14 </Package>
15
16 <Fragment>
13 - <StandardDirectory Id="ProgramFilesFolder">
14 - <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
15 - </StandardDirectory>
16 - </Fragment>
17 + <StandardDirectory Id="ProgramFilesFolder">
18 + <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
19 + </StandardDirectory>
20 + </Fragment>
21 </Wix>
src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs
+10 -1
@@ -5,6 +5,7 @@ namespace WixToolset.Core.Link
5 using System.Collections.Generic;
6 using System.Linq;
7 using WixToolset.Data;
8 + using WixToolset.Data.Symbols;
9 using WixToolset.Extensibility.Services;
10
11 internal class ReportConflictingSymbolsCommand
@@ -62,7 +63,15 @@ namespace WixToolset.Core.Link
63
64 reportDuplicates = virtualConflicts;
65
65 - this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber));
66 + switch (first.Symbol)
67 + {
68 + case WixActionSymbol action:
69 + this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(action));
70 + break;
71 + default:
72 + this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber));
73 + break;
74 + }
75 }
76 else
77 {
src/wix/WixToolset.Core/LinkerErrors.cs
+6
@@ -3,6 +3,7 @@
3 namespace WixToolset.Core
4 {
5 using WixToolset.Data;
6 + using WixToolset.Data.Symbols;
7
8 internal static class LinkerErrors
9 {
@@ -101,6 +102,11 @@ namespace WixToolset.Core
102 return Message(symbol.SourceLineNumbers, Ids.VirtualSymbolMustBeOverridden, "The {0} symbol '{1}' conflicts with a virtual symbol. Use the 'override' access modifier to override the virtual symbol or use a different Id to avoid the conflict.", symbol.Definition.Name, symbol.Id.Id);
103 }
104
105 + public static Message VirtualSymbolMustBeOverridden(WixActionSymbol actionSymbol)
106 + {
107 + return Message(actionSymbol.SourceLineNumbers, Ids.VirtualSymbolMustBeOverridden, "The action '{0}' conflicts with a virtual symbol with the same id. To override the virtual symbol (e.g., to reschedule a custom action), use the 'override' access modifier: 'override {0}'. If you didn't intend to override a virtual symbol, use a different id to avoid the conflict.", actionSymbol.Action);
108 + }
109 +
110 public static Message VirtualSymbolMustBeOverridden(IntermediateSymbol symbol, SourceLineNumber referencingSourceLineNumber)
111 {
112 if (referencingSourceLineNumber is null)