Skip to content

Commit

Permalink
Add references to Standard Actions based on Tables that are included
Browse files Browse the repository at this point in the history
in EnsureTables symbols (from Extensions).

This should handle dependencies from Extensions back to Standard Actions
that are coupled to Standard Tables.
  • Loading branch information
bevanweiss committed Aug 7, 2024
1 parent ce73352 commit 45bd53d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class WindowsInstallerStandard
{
private static readonly Dictionary<string, WixActionSymbol> standardActionsById;
private static readonly HashSet<string> standardActionNames;
private static readonly Dictionary<string, WixActionSymbol[]> standardActionsByTableName = new Dictionary<string, WixActionSymbol[]>();

/// <summary>
/// References:
Expand Down Expand Up @@ -368,6 +369,26 @@ static WindowsInstallerStandard()

standardActionNames = new HashSet<string>(standardActions.Select(a => a.Action));
standardActionsById = standardActions.ToDictionary(a => a.Id.Id);

// Populate standard actions based on standard table names
standardActionsByTableName.Add("AppId", new[]
{
standardActionsById["AdvertiseExecuteSequence/RegisterClassInfo"],
standardActionsById["InstallExecuteSequence/UnregisterClassInfo"],
standardActionsById["InstallExecuteSequence/RegisterClassInfo"],
});
standardActionsByTableName.Add("AppSearch", new[]
{
standardActionsById["InstallUISequence/AppSearch"],
standardActionsById["InstallExecuteSequence/AppSearch"],
});
standardActionsByTableName.Add("BindImage", new[] { standardActionsById["InstallExecuteSequence/BindImage"] });
standardActionsByTableName.Add("RemoveFile", new[] { standardActionsById["InstallExecuteSequence/RemoveFiles"] });
standardActionsByTableName.Add("Registry", new[]
{
standardActionsById["InstallExecuteSequence/WriteRegistryValues"],
standardActionsById["InstallExecuteSequence/RemoveRegistryValues"],
});
}

/// <summary>
Expand Down Expand Up @@ -457,6 +478,14 @@ public static bool TryGetStandardAction(string sequenceName, string actioname, o
return standardActionsById.TryGetValue(String.Concat(sequenceName, "/", actioname), out standardAction);
}

/// <summary>
/// Try to get standard actions associated with a table definition.
/// </summary>
public static bool TryGetTableAssociatedStandardActions(string tableName, out WixActionSymbol[] standardActions)
{
return standardActionsByTableName.TryGetValue(tableName, out standardActions);
}

/// <summary>
/// Try to get standard directory name by id.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ private Dictionary<string, WixActionSymbol> GetRequiredStandardActions()
overridableActionSymbols.Add(standardAction.Id.Id, standardAction);
}

// Get the Standard Actions associated with EnsureTable symbols.
foreach (var table in this.Section.Symbols.OfType<WixEnsureTableSymbol>())
{
if (WindowsInstallerStandard.TryGetTableAssociatedStandardActions(table.Table, out var standardActions))
{
foreach(var standardAction in standardActions)
{
if (!overridableActionSymbols.ContainsKey(standardAction.Id.Id))
{
overridableActionSymbols.Add(standardAction.Id.Id, standardAction);
}
}
}
}

return overridableActionSymbols;
}

Expand Down

0 comments on commit 45bd53d

Please sign in to comment.