Skip to content

Commit 7799a2f

Browse files
committed
Fix validate errors
1 parent 13461f7 commit 7799a2f

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

tasks/msi.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from invoke.exceptions import Exit, UnexpectedExit
1818

1919
from tasks.libs.ciproviders.gitlab_api import get_gitlab_repo
20-
from tasks.libs.common.utils import download_to_tempfile, timed
20+
from tasks.libs.common.utils import download_to_tempfile, running_in_ci, timed
2121
from tasks.libs.dependencies import get_effective_dependencies_env
2222
from tasks.libs.releasing.version import VERSION_RE, _create_version_from_match, get_version
2323

@@ -135,6 +135,11 @@ def _ensure_wix_tools(ctx):
135135
# Note: .NET global tools are invoked directly by name, not with 'dotnet' prefix
136136
result = ctx.run('wix --version', warn=True, hide=True)
137137
if not result or result.return_code != 0:
138+
if running_in_ci():
139+
raise Exit(
140+
"WiX tools not found in CI.",
141+
code=1,
142+
)
138143
# Install WiX 5.x globally
139144
print(f"WiX tools not found. Installing WiX {WIX_VERSION} globally...")
140145
result = ctx.run(f'dotnet tool install --global wix --version {WIX_VERSION}', warn=True)
@@ -177,11 +182,14 @@ def _ensure_wix_extensions(ctx, extensions, version):
177182
print(f"WiX extension {expected} already installed")
178183
continue
179184
else:
185+
if running_in_ci():
186+
raise Exit(
187+
f"WiX extension {ext} has wrong version {installed_extensions[ext]} in CI, need {version}.",
188+
code=1,
189+
)
180190
# Wrong version installed - remove it first
181191
print(f"Removing incompatible WiX extension {ext}/{installed_extensions[ext]}...")
182192
ctx.run(f'wix extension remove -g {ext}', warn=True, hide=True)
183-
184-
# Install the extension with the correct version
185193
print(f"Installing WiX extension {expected}...")
186194
result = ctx.run(f'wix extension add -g {expected}', warn=True)
187195
if not result or result.return_code != 0:
@@ -278,6 +286,7 @@ def _build_wxs(ctx, env, outdir, ca_dll):
278286
raise Exit("Failed to build the MSI WXS.", code=1)
279287

280288
# sign the MakeSfxCA output files
289+
# If signing fails due to corrupted PE file / signature, it may be a regression caused by the makesfxca template DLL being previously signed before the embedded files were added to it. For more information refer to `_fix_makesfxca_dll` from `msi.py` in the git history.
281290
sign_file(ctx, os.path.join(outdir, ca_dll))
282291

283292

@@ -551,7 +560,9 @@ def validate_msi_createfolder_table(db, allowlist):
551560

552561

553562
@task
554-
def validate_msi(_, allowlist, msi=None):
563+
def validate_msi(ctx, allowlist, msi=None):
564+
print(f"Validating MSI")
565+
ctx.run(f'wix msi validate "{msi}"')
555566
with MsiClosing(msilib.OpenDatabase(msi, msilib.MSIDBOPEN_READONLY)) as db:
556567
validate_msi_createfolder_table(db, allowlist)
557568

tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentCustomActions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public AgentCustomActions()
586586
Impersonate = false
587587
}
588588
.SetProperties("DDAGENTUSER_PROCESSED_PASSWORD=[DDAGENTUSER_PROCESSED_PASSWORD], " +
589-
"DDAGENTUSER_PROCESSED_FQ_NAME=[DDAGENTUSER_PROCESSED_FQ_NAME], ")
589+
"DDAGENTUSER_PROCESSED_FQ_NAME=[DDAGENTUSER_PROCESSED_FQ_NAME]")
590590
.HideTarget(true);
591591

592592
ConfigureServicesRollback = new CustomAction<CustomActions>(
@@ -601,7 +601,7 @@ public AgentCustomActions()
601601
Execute = Execute.rollback,
602602
Impersonate = false
603603
}
604-
.SetProperties("DDAGENTUSER_PROCESSED_FQ_NAME=[DDAGENTUSER_PROCESSED_FQ_NAME], ")
604+
.SetProperties("DDAGENTUSER_PROCESSED_FQ_NAME=[DDAGENTUSER_PROCESSED_FQ_NAME]")
605605
.HideTarget(true);
606606

607607
// WiX built-in StopServices only stops services if the component is changing.

tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,10 @@ public Project Configure()
362362
// to be left behind on uninstall.
363363
document.FindAll("CreateFolder")
364364
.ForEach(x => x.Remove());
365+
// Remove auto-generated RemoveFolder elements, except for ProgramMenuDatadog which is needed
366+
// for ICE64 compliance (user profile directories must be in RemoveFile table).
365367
document.FindAll("RemoveFolder")
368+
.Where(x => !x.HasAttribute("Id", value => value.Contains("ProgramMenuDatadog")))
366369
.ForEach(x => x.Remove());
367370

368371
// Wix# is auto-adding components for the following directories for some reason, which causes them to be placed

tools/windows/DatadogAgentInstaller/WixSetup/MutuallyExclusiveProduct.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public MutuallyExclusiveProducts(string productName, Guid upgradeCode)
3131
///
3232
/// Example WiX:
3333
/// <Upgrade Id="PUT-GUID-HERE">
34-
/// <UpgradeVersion Minimum="0.0.0.0" IncludeMinimum="yes" OnlyDetect="yes" Maximum="255.255.0.0" IncludeMaximum="no" Property="MUTUALLY_EXCLUSIVE_PRODUCTS_1" />
34+
/// <UpgradeVersion Minimum="0.0.0" IncludeMinimum="yes" OnlyDetect="yes" Property="MUTUALLY_EXCLUSIVE_PRODUCTS_1" />
3535
/// </Upgrade>
3636
/// <Condition Message="This product cannot be installed at the same time as [ProductName]. Please uninstall [ProductName] before continuing.">NOT MUTUALLY_EXCLUSIVE_PRODUCTS_1</Condition>
3737
/// <Property Id="MUTUALLY_EXCLUSIVE_PRODUCTS_1" Secure="yes" />
@@ -51,14 +51,13 @@ public void Process(ProcessingContext context)
5151
var upgradeElement = new XElement("Upgrade");
5252
upgradeElement.SetAttributeValue("Id", UpgradeCode);
5353

54+
// Note: UpgradeVersion does NOT have an Id attribute in WiX 5
55+
// Detect all versions of the conflicting product.
56+
// Omitting Maximum means "no upper bound" - detects all versions >= Minimum.
5457
var upgradeVersionElement = new XElement("UpgradeVersion",
55-
new XAttribute("Minimum", "0.0.0.0"),
58+
new XAttribute("Minimum", "0.0.0"),
5659
new XAttribute("IncludeMinimum", "yes"),
5760
new XAttribute("OnlyDetect", "yes"),
58-
// 255 is the maximum
59-
// https://learn.microsoft.com/en-us/windows/win32/msi/productversion
60-
new XAttribute("Maximum", "255.255.0.0"),
61-
new XAttribute("IncludeMaximum", "yes"),
6261
new XAttribute("Property", propertyName)
6362
);
6463
upgradeElement.Add(upgradeVersionElement);

0 commit comments

Comments
 (0)