Skip to content

Commit

Permalink
Add runtime location to host log (#3806)
Browse files Browse the repository at this point in the history
Add runtime location to host log
  • Loading branch information
MarcoRossignoli committed Jun 24, 2022
1 parent 8f7fba5 commit 5b3bb9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/testhost.x86/DefaultEngineInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading;
Expand Down Expand Up @@ -100,7 +101,16 @@ public void Invoke(IDictionary<string, string?> argsDictionary)
.GetTypeInfo()
.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
EqtTrace.Verbose($"Version: {version}");
EqtTrace.Verbose($"Version: {version} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}");
#if NETCOREAPP2_0_OR_GREATER || NETFRAMEWORK
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-6.0#remarks
// In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string.
string objectTypeLocation = typeof(object).Assembly.Location;
if (!objectTypeLocation.IsNullOrEmpty())
{
EqtTrace.Verbose($"Runtime location: {Path.GetDirectoryName(objectTypeLocation)}");
}
#endif
}

if (EqtTrace.IsInfoEnabled)
Expand Down
7 changes: 7 additions & 0 deletions src/vstest.console/Processors/EnableDiagArgumentProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ public void Initialize(string? argument)
// Write version to the log here, because that is the
// first place where we know if we log or not.
EqtTrace.Verbose($"Version: {Product.Version} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}");
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-6.0#remarks
// In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string.
string objectTypeLocation = typeof(object).Assembly.Location;
if (!objectTypeLocation.IsNullOrEmpty())
{
EqtTrace.Verbose($"Runtime location: {Path.GetDirectoryName(objectTypeLocation)}");
}
}

/// <summary>
Expand Down

0 comments on commit 5b3bb9c

Please sign in to comment.