Skip to content

Commit 5b3bb9c

Browse files
Add runtime location to host log (#3806)
Add runtime location to host log
1 parent 8f7fba5 commit 5b3bb9c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/testhost.x86/DefaultEngineInvoker.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Globalization;
7+
using System.IO;
78
using System.Net;
89
using System.Reflection;
910
using System.Threading;
@@ -100,7 +101,16 @@ public void Invoke(IDictionary<string, string?> argsDictionary)
100101
.GetTypeInfo()
101102
.Assembly
102103
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
103-
EqtTrace.Verbose($"Version: {version}");
104+
EqtTrace.Verbose($"Version: {version} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}");
105+
#if NETCOREAPP2_0_OR_GREATER || NETFRAMEWORK
106+
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-6.0#remarks
107+
// In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string.
108+
string objectTypeLocation = typeof(object).Assembly.Location;
109+
if (!objectTypeLocation.IsNullOrEmpty())
110+
{
111+
EqtTrace.Verbose($"Runtime location: {Path.GetDirectoryName(objectTypeLocation)}");
112+
}
113+
#endif
104114
}
105115

106116
if (EqtTrace.IsInfoEnabled)

src/vstest.console/Processors/EnableDiagArgumentProcessor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ public void Initialize(string? argument)
138138
// Write version to the log here, because that is the
139139
// first place where we know if we log or not.
140140
EqtTrace.Verbose($"Version: {Product.Version} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}");
141+
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-6.0#remarks
142+
// In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string.
143+
string objectTypeLocation = typeof(object).Assembly.Location;
144+
if (!objectTypeLocation.IsNullOrEmpty())
145+
{
146+
EqtTrace.Verbose($"Runtime location: {Path.GetDirectoryName(objectTypeLocation)}");
147+
}
141148
}
142149

143150
/// <summary>

0 commit comments

Comments
 (0)