Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the 32bit experience when installing the 64bit agent. #1890

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Agent/MsiInstaller/Installer/Product.wxs
Original file line number Diff line number Diff line change
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>
chynesNR marked this conversation as resolved.
Show resolved Hide resolved
<?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
Loading
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
Loading
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
Original file line number Diff line number Diff line change
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
Loading