Skip to content

Commit

Permalink
The RemoveFoldersEx custom action relies upon pushing rows to the
Browse files Browse the repository at this point in the history
RemoveFile standard MSI table, and then expected the RemoveFiles standard
MSI action to pick up the rows and do the removal actions.
However without install files, we don't add in RemoveFiles scheduling.

This commit creates a new pair of methods for the ParseHelper which allow
for a similar EnsureXXX flow as the existing EnsureTable method, but for
Standard Actions.


Signed-off-by: Bevan Weiss <[email protected]>
  • Loading branch information
bevanweiss committed Aug 2, 2024
1 parent ce73352 commit bb40df4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/api/wix/WixToolset.Data/ErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,11 @@ public static Message SplitCabinetNameCollision(string newCabName, string firstC
return Message(null, Ids.SplitCabinetNameCollision, "The cabinet name '{0}' collides with the new cabinet formed by splitting cabinet '{1}', consider renaming cabinet '{0}'.", newCabName, firstCabName);
}

public static Message StandardActionInvalid(SourceLineNumber sourceLineNumbers, string actionId)
{
return Message(sourceLineNumbers, Ids.StandardActionInvalid, "An invalid Standard Action '{0}' was specified as being required.", actionId);
}

public static Message StandardActionRelativelyScheduledInModule(SourceLineNumber sourceLineNumbers, string sequenceTableName, string actionName)
{
return Message(sourceLineNumbers, Ids.StandardActionRelativelyScheduledInModule, "The {0} table contains a standard action '{1}' that does not have a sequence number specified. The Sequence attribute is required for standard actions in a merge module. Please remove the action or use the Sequence attribute.", sequenceTableName, actionName);
Expand Down Expand Up @@ -2667,6 +2672,7 @@ public enum Ids
MsiTransactionInvalidPackage2 = 412,
ExpectedAttributeOrElementWithOtherAttribute = 413,
ExpectedAttributeOrElementWithoutOtherAttribute = 414,
StandardActionInvalid = 415
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.

namespace WixToolset.Data.WindowsInstaller
{
using System;

/// <summary>
/// Exception thrown when an invalid Standard Action is referenced.
/// </summary>
[Serializable]
public class WixInvalidStandardActionException : WixException
{
/// <summary>
/// Instantiate new WixInvalidStandardActionException.
/// </summary>
/// <param name="error">Localized error information.</param>
public WixInvalidStandardActionException(Message error)
: base(error)
{
}
}
}
21 changes: 19 additions & 2 deletions src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,37 @@ public interface IParseHelper
/// <returns>True if a property is found in the string.</returns>
bool ContainsProperty(string possibleProperty);

/// <summary>
/// Add the appropriate symbols to make sure that the given Standard Action shows up in the resulting output.
/// </summary>
/// <param name="section">Active section.</param>
/// <param name="sourceLineNumbers">Source line numbers.</param>
/// <param name="id">Id of the Standard Action to ensure existence of. e.g. "InstallExecuteSequence/RemoveFiles"</param>
void EnsureStandardAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, string id);

/// <summary>
/// Add the appropriate symbols to make sure that the given Standard Action shows up in the resulting output.
/// </summary>
/// <param name="section">Active section.</param>
/// <param name="sourceLineNumbers">Source line numbers.</param>
/// <param name="sequenceName">Name of the sequence in which the Standard Action exists.</param>
/// <param name="actionName">Name of the Standard Action to ensure existence of.</param>
void EnsureStandardAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, string sequenceName, string actionName);

/// <summary>
/// Add the appropriate symbols to make sure that the given table shows up in the resulting output.
/// </summary>
/// <param name="section">Active section.</param>
/// <param name="sourceLineNumbers">Source line numbers.</param>
/// <param name="tableName">Name of the table to ensure existance of.</param>
/// <param name="tableName">Name of the table to ensure existence of.</param>
void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName);

/// <summary>
/// Add the appropriate symbols to make sure that the given table shows up in the resulting output.
/// </summary>
/// <param name="section">Active section.</param>
/// <param name="sourceLineNumbers">Source line numbers.</param>
/// <param name="tableDefinition">Definition of the table to ensure existance of.</param>
/// <param name="tableDefinition">Definition of the table to ensure existence of.</param>
void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition);

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/ext/Util/wixext/UtilCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,7 @@ private void ParseRemoveFolderExElement(Intermediate intermediate, IntermediateS
});

this.ParseHelper.EnsureTable(section, sourceLineNumbers, "RemoveFile");
this.ParseHelper.EnsureStandardAction(section, sourceLineNumbers, "InstallExecuteSequence/RemoveFiles");
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,24 @@ public IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNu
return section.AddSymbol(symbolDefinition.CreateSymbol(sourceLineNumbers, identifier));
}

public void EnsureStandardAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, string id)
{
if (!WindowsInstallerStandard.TryGetStandardAction(id, out WixActionSymbol standardAction))
{
throw new WixInvalidStandardActionException(ErrorMessages.StandardActionInvalid(sourceLineNumbers, id));
}
section.AddSymbol(standardAction);
}

public void EnsureStandardAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, string sequenceName, string actionName)
{
if (!WindowsInstallerStandard.TryGetStandardAction(sequenceName, actionName, out WixActionSymbol standardAction))
{
throw new WixInvalidStandardActionException(ErrorMessages.StandardActionInvalid(sourceLineNumbers, $"{sequenceName}/{actionName}"));
}
section.AddSymbol(standardAction);
}

public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition)
{
section.AddSymbol(new WixEnsureTableSymbol(sourceLineNumbers)
Expand Down

0 comments on commit bb40df4

Please sign in to comment.