From eb09813b4f92d6e5934d02b5f381a0cdef9b0439 Mon Sep 17 00:00:00 2001 From: Julien Lebot Date: Wed, 8 Nov 2023 17:28:08 +0100 Subject: [PATCH] [Windows][Installer] Fix `NullReferenceException` when `INSTALL_CWS` is `null` (#20717) --- .../WixSetup/Datadog/AgentInstaller.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog/AgentInstaller.cs b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog/AgentInstaller.cs index fc6d09d881ba4..c58e0f49bf381 100644 --- a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog/AgentInstaller.cs +++ b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog/AgentInstaller.cs @@ -58,13 +58,6 @@ public AgentInstaller(string version = null) public Project ConfigureProject() { - // Conditionally include the PROCMON MSM while it is in active development to make it easier - // to build/ship without it. - Property cwsProperty = null; - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WINDOWS_DDPROCMON_DRIVER"))) - { - cwsProperty = new Property("INSTALL_CWS", "1"); - } var project = new ManagedProject("Datadog Agent", // Use 2 LaunchConditions, one for server versions, // one for client versions. @@ -128,12 +121,16 @@ public Project ConfigureProject() ) { Win64 = true - }, - // cwsProperty is conditionally declared above, it is either NULL - // or the property indicating that cws is to be included. - cwsProperty + } ); + // Conditionally include the PROCMON MSM while it is in active development to make it easier + // to build/ship without it. + if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WINDOWS_DDPROCMON_DRIVER"))) + { + project.AddProperty(new Property("INSTALL_CWS", "1")); + } + // Always generate a new GUID otherwise WixSharp will generate one based on // the version project.ProductId = Guid.NewGuid();