Skip to content

Commit

Permalink
summary: Improve the 32bit experience when installing the 64bit agent. (
Browse files Browse the repository at this point in the history
#1890)

feat: Prevent using different bitness installer when in-place upgrading. (#1890)
feat: Add 32bit profiler path to IIS registry when installing 64bit agent. (#1890)
chore: Update branding to match current standards. (#1890)
  • Loading branch information
jaffinito committed Sep 7, 2023
1 parent 541dd2c commit 65dd50b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Agent/MsiInstaller/Installer/Product.wxs
Expand Up @@ -190,12 +190,13 @@ SPDX-License-Identifier: Apache-2.0
<CustomAction Id="CleanupPreviousInstall" BinaryKey="CustomActionsDll" DllEntry="CleanupPreviousInstall" Execute="deferred" Impersonate="no" Return="check"/>
<CustomAction Id='RestartIis' BinaryKey="CustomActionsDll" DllEntry="RestartIis" Impersonate="yes"/>
<CustomAction Id='CloseStatusMonitor' BinaryKey="CustomActionsDll" DllEntry="CloseStatusMonitor" Impersonate="yes"/>
<CustomAction Id="CheckBitness" BinaryKey="CustomActionsDll" DllEntry="CheckBitness" Execute="immediate" Return="check"/>

<!-- Run the custom actions at the beginning of the install. -->
<InstallUISequence>

<Custom Action="CheckBitness" Before="CostInitialize" />
</InstallUISequence>

<!-- Run the custom actions at the end of the install. -->
<InstallExecuteSequence>
<Custom Action="FindPreviousLicenseKey" After="CostFinalize">NOT Installed</Custom>
Expand Down Expand Up @@ -809,13 +810,19 @@ SPDX-License-Identifier: Apache-2.0
<MultiStringValue>COR_ENABLE_PROFILING=1</MultiStringValue>
<MultiStringValue>COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}</MultiStringValue>
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
<?ifdef IsWin64?>
<MultiStringValue>COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
<?endif?>
</RegistryValue>
</Component>
<Component Id="WASRegistryComponent" Guid="*">
<RegistryValue Root="HKLM" Key="System\CurrentControlSet\Services\WAS" Name="Environment" Type="multiString" Action="append" KeyPath="yes">
<MultiStringValue>COR_ENABLE_PROFILING=1</MultiStringValue>
<MultiStringValue>COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}</MultiStringValue>
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
<?ifdef IsWin64?>
<MultiStringValue>COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
<?endif?>
</RegistryValue>
</Component>
</ComponentGroup>
Expand All @@ -827,6 +834,9 @@ SPDX-License-Identifier: Apache-2.0
<MultiStringValue>CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}</MultiStringValue>
<MultiStringValue>CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER]</MultiStringValue>
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
<?ifdef IsWin64?>
<MultiStringValue>CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
<?endif?>
</RegistryValue>
</Component>
<Component Id="CoreWASRegistryComponent" Guid="{DD918B05-5DEE-49F0-B9B6-3ACAD06AD400}">
Expand All @@ -835,6 +845,9 @@ SPDX-License-Identifier: Apache-2.0
<MultiStringValue>CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}</MultiStringValue>
<MultiStringValue>CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER]</MultiStringValue>
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
<?ifdef IsWin64?>
<MultiStringValue>CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
<?endif?>
</RegistryValue>
</Component>
</ComponentGroup>
Expand Down
Binary file modified src/Agent/MsiInstaller/Installer/ui-banner.bmp
Binary file not shown.
Binary file modified src/Agent/MsiInstaller/Installer/ui-banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Agent/MsiInstaller/Installer/ui-dialog.bmp
Binary file not shown.
Binary file modified src/Agent/MsiInstaller/Installer/ui-dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 111 additions & 0 deletions src/Agent/MsiInstaller/InstallerActions/CustomActions.cs
Expand Up @@ -4,9 +4,11 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;

namespace InstallerActions
{
Expand Down Expand Up @@ -184,6 +186,115 @@ public static ActionResult CloseStatusMonitor(Session session)
return ActionResult.Success;
}

[CustomAction]
public static ActionResult CheckBitness(Session session)
{
try
{
var uninstallPaths = new string[] {
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall" };

// check 64-bit first and then 32-bit if needed.
string displayName = null;
foreach (var path in uninstallPaths)
{
if (string.IsNullOrEmpty(displayName))
{
displayName = GetDisplayName(path);
}
}

// didn't find NR so not installed.
if (displayName == null)
{
return ActionResult.Success;
}

var productName = session["ProductName"];
if (displayName == productName)
{
return ActionResult.Success;
}

session.Message(InstallMessage.FatalExit, BuildBitnessErrorRecord(productName));
return ActionResult.Failure;
}
catch(Exception exception)
{
session.Log("Exception thrown checking bitness:\n{0}", exception);
return ActionResult.Failure;
}
}

private static string GetDisplayName(string path)
{
try
{
var regKey = Registry.LocalMachine.OpenSubKey(path);
foreach (var subkeyName in regKey.GetSubKeyNames())
{
// Our key a a guid so skip anything that is not.
if (!subkeyName.StartsWith("{"))
{
continue;
}

// Some entries are missing the DisplayName value.
var subkey = regKey.OpenSubKey(subkeyName);
if (!HasDisplayName(subkey.GetValueNames()))
{
continue;
}

var displayName = subkey.GetValue("DisplayName").ToString();
if (string.IsNullOrEmpty(displayName) || !displayName.StartsWith("New Relic .NET Agent"))
{
continue;
}

// we have a new relic displayname here.
return displayName;
}
}
catch
{}

return null;
}

private static Record BuildBitnessErrorRecord(string productName)
{
var builder = new StringBuilder();
if (productName == "New Relic .NET Agent (64-bit)")
{
builder.AppendLine("The installed x86 (32-bit) version of the New Relic .NET Agent is not compatible with this 64-bit installer.");
builder.AppendLine();
builder.AppendLine("Either remove the existing installation or use the x86 (32-bit) installer.");
}
else
{
builder.AppendLine("The installed 64-bit version of the New Relic .NET Agent is not compatible with this x86 (32-bit) installer.");
builder.AppendLine();
builder.AppendLine("Either remove the existing installation or use the 64-bit installer.");
}

return new Record { FormatString = builder.ToString() };
}

private static bool HasDisplayName(string[] values)
{
for (int i = 0; i < values.Length; i++)
{
if (values[i] == "DisplayName")
{
return true;
}
}

return false;
}

public static void Log(Session session, string message, params object[] arguments)
{
session["LogHack"] = String.Format(message, arguments);
Expand Down

0 comments on commit 65dd50b

Please sign in to comment.