Skip to content

Commit

Permalink
Improve error when virtual action symbols collide.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnson committed Feb 5, 2024
1 parent bf1e74b commit eb2f85d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
@@ -1,4 +1,4 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

Expand All @@ -7,11 +7,15 @@
</Feature>

<util:CloseApplication Id="CloseMyApp" CloseMessage="yes" Property="MYAPPISRUNNING" Target="explorer.exe" />

<InstallExecuteSequence>
<Custom Action="override Wix4CloseApplications_$(sys.BUILDARCHSHORT)" After="InstallInitialize" />
</InstallExecuteSequence>
</Package>

<Fragment>
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MsiPackage" />
</StandardDirectory>
</Fragment>
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MsiPackage" />
</StandardDirectory>
</Fragment>
</Wix>
11 changes: 10 additions & 1 deletion src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs
Expand Up @@ -5,6 +5,7 @@ namespace WixToolset.Core.Link
using System.Collections.Generic;
using System.Linq;
using WixToolset.Data;
using WixToolset.Data.Symbols;
using WixToolset.Extensibility.Services;

internal class ReportConflictingSymbolsCommand
Expand Down Expand Up @@ -62,7 +63,15 @@ public void Execute()

reportDuplicates = virtualConflicts;

this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber));
switch (first.Symbol)
{
case WixActionSymbol action:
this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(action));
break;
default:
this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber));
break;
}
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions src/wix/WixToolset.Core/LinkerErrors.cs
Expand Up @@ -3,6 +3,7 @@
namespace WixToolset.Core
{
using WixToolset.Data;
using WixToolset.Data.Symbols;

internal static class LinkerErrors
{
Expand Down Expand Up @@ -101,6 +102,11 @@ public static Message VirtualSymbolMustBeOverridden(IntermediateSymbol symbol)
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);
}

public static Message VirtualSymbolMustBeOverridden(WixActionSymbol actionSymbol)
{
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);
}

public static Message VirtualSymbolMustBeOverridden(IntermediateSymbol symbol, SourceLineNumber referencingSourceLineNumber)
{
if (referencingSourceLineNumber is null)
Expand Down

0 comments on commit eb2f85d

Please sign in to comment.