Skip to content

Commit 65dd50b

Browse files
authored
summary: Improve the 32bit experience when installing the 64bit agent. (#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)
1 parent 541dd2c commit 65dd50b

File tree

6 files changed

+126
-2
lines changed

6 files changed

+126
-2
lines changed

src/Agent/MsiInstaller/Installer/Product.wxs

+15-2
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,13 @@ SPDX-License-Identifier: Apache-2.0
190190
<CustomAction Id="CleanupPreviousInstall" BinaryKey="CustomActionsDll" DllEntry="CleanupPreviousInstall" Execute="deferred" Impersonate="no" Return="check"/>
191191
<CustomAction Id='RestartIis' BinaryKey="CustomActionsDll" DllEntry="RestartIis" Impersonate="yes"/>
192192
<CustomAction Id='CloseStatusMonitor' BinaryKey="CustomActionsDll" DllEntry="CloseStatusMonitor" Impersonate="yes"/>
193+
<CustomAction Id="CheckBitness" BinaryKey="CustomActionsDll" DllEntry="CheckBitness" Execute="immediate" Return="check"/>
193194

194195
<!-- Run the custom actions at the beginning of the install. -->
195196
<InstallUISequence>
196-
197+
<Custom Action="CheckBitness" Before="CostInitialize" />
197198
</InstallUISequence>
198-
199+
199200
<!-- Run the custom actions at the end of the install. -->
200201
<InstallExecuteSequence>
201202
<Custom Action="FindPreviousLicenseKey" After="CostFinalize">NOT Installed</Custom>
@@ -809,13 +810,19 @@ SPDX-License-Identifier: Apache-2.0
809810
<MultiStringValue>COR_ENABLE_PROFILING=1</MultiStringValue>
810811
<MultiStringValue>COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}</MultiStringValue>
811812
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
813+
<?ifdef IsWin64?>
814+
<MultiStringValue>COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
815+
<?endif?>
812816
</RegistryValue>
813817
</Component>
814818
<Component Id="WASRegistryComponent" Guid="*">
815819
<RegistryValue Root="HKLM" Key="System\CurrentControlSet\Services\WAS" Name="Environment" Type="multiString" Action="append" KeyPath="yes">
816820
<MultiStringValue>COR_ENABLE_PROFILING=1</MultiStringValue>
817821
<MultiStringValue>COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}</MultiStringValue>
818822
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
823+
<?ifdef IsWin64?>
824+
<MultiStringValue>COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
825+
<?endif?>
819826
</RegistryValue>
820827
</Component>
821828
</ComponentGroup>
@@ -827,6 +834,9 @@ SPDX-License-Identifier: Apache-2.0
827834
<MultiStringValue>CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}</MultiStringValue>
828835
<MultiStringValue>CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER]</MultiStringValue>
829836
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
837+
<?ifdef IsWin64?>
838+
<MultiStringValue>CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
839+
<?endif?>
830840
</RegistryValue>
831841
</Component>
832842
<Component Id="CoreWASRegistryComponent" Guid="{DD918B05-5DEE-49F0-B9B6-3ACAD06AD400}">
@@ -835,6 +845,9 @@ SPDX-License-Identifier: Apache-2.0
835845
<MultiStringValue>CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A}</MultiStringValue>
836846
<MultiStringValue>CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER]</MultiStringValue>
837847
<MultiStringValue>NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER]</MultiStringValue>
848+
<?ifdef IsWin64?>
849+
<MultiStringValue>CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll</MultiStringValue>
850+
<?endif?>
838851
</RegistryValue>
839852
</Component>
840853
</ComponentGroup>
82 Bytes
Binary file not shown.
-26.5 KB
Loading
82 Bytes
Binary file not shown.
-66.7 KB
Loading

src/Agent/MsiInstaller/InstallerActions/CustomActions.cs

+111
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
using System;
55
using System.Diagnostics;
66
using System.IO;
7+
using System.Text;
78
using System.Xml;
89
using System.Xml.XPath;
910
using Microsoft.Deployment.WindowsInstaller;
11+
using Microsoft.Win32;
1012

1113
namespace InstallerActions
1214
{
@@ -184,6 +186,115 @@ public static ActionResult CloseStatusMonitor(Session session)
184186
return ActionResult.Success;
185187
}
186188

189+
[CustomAction]
190+
public static ActionResult CheckBitness(Session session)
191+
{
192+
try
193+
{
194+
var uninstallPaths = new string[] {
195+
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
196+
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall" };
197+
198+
// check 64-bit first and then 32-bit if needed.
199+
string displayName = null;
200+
foreach (var path in uninstallPaths)
201+
{
202+
if (string.IsNullOrEmpty(displayName))
203+
{
204+
displayName = GetDisplayName(path);
205+
}
206+
}
207+
208+
// didn't find NR so not installed.
209+
if (displayName == null)
210+
{
211+
return ActionResult.Success;
212+
}
213+
214+
var productName = session["ProductName"];
215+
if (displayName == productName)
216+
{
217+
return ActionResult.Success;
218+
}
219+
220+
session.Message(InstallMessage.FatalExit, BuildBitnessErrorRecord(productName));
221+
return ActionResult.Failure;
222+
}
223+
catch(Exception exception)
224+
{
225+
session.Log("Exception thrown checking bitness:\n{0}", exception);
226+
return ActionResult.Failure;
227+
}
228+
}
229+
230+
private static string GetDisplayName(string path)
231+
{
232+
try
233+
{
234+
var regKey = Registry.LocalMachine.OpenSubKey(path);
235+
foreach (var subkeyName in regKey.GetSubKeyNames())
236+
{
237+
// Our key a a guid so skip anything that is not.
238+
if (!subkeyName.StartsWith("{"))
239+
{
240+
continue;
241+
}
242+
243+
// Some entries are missing the DisplayName value.
244+
var subkey = regKey.OpenSubKey(subkeyName);
245+
if (!HasDisplayName(subkey.GetValueNames()))
246+
{
247+
continue;
248+
}
249+
250+
var displayName = subkey.GetValue("DisplayName").ToString();
251+
if (string.IsNullOrEmpty(displayName) || !displayName.StartsWith("New Relic .NET Agent"))
252+
{
253+
continue;
254+
}
255+
256+
// we have a new relic displayname here.
257+
return displayName;
258+
}
259+
}
260+
catch
261+
{}
262+
263+
return null;
264+
}
265+
266+
private static Record BuildBitnessErrorRecord(string productName)
267+
{
268+
var builder = new StringBuilder();
269+
if (productName == "New Relic .NET Agent (64-bit)")
270+
{
271+
builder.AppendLine("The installed x86 (32-bit) version of the New Relic .NET Agent is not compatible with this 64-bit installer.");
272+
builder.AppendLine();
273+
builder.AppendLine("Either remove the existing installation or use the x86 (32-bit) installer.");
274+
}
275+
else
276+
{
277+
builder.AppendLine("The installed 64-bit version of the New Relic .NET Agent is not compatible with this x86 (32-bit) installer.");
278+
builder.AppendLine();
279+
builder.AppendLine("Either remove the existing installation or use the 64-bit installer.");
280+
}
281+
282+
return new Record { FormatString = builder.ToString() };
283+
}
284+
285+
private static bool HasDisplayName(string[] values)
286+
{
287+
for (int i = 0; i < values.Length; i++)
288+
{
289+
if (values[i] == "DisplayName")
290+
{
291+
return true;
292+
}
293+
}
294+
295+
return false;
296+
}
297+
187298
public static void Log(Session session, string message, params object[] arguments)
188299
{
189300
session["LogHack"] = String.Format(message, arguments);

0 commit comments

Comments
 (0)