From 196f00332348a792e30d598c2427281e971dd761 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Mon, 24 Aug 2020 17:36:18 +0200 Subject: [PATCH] Print version of the product in log --- TestPlatform.sln | 1 + src/datacollector/DataCollectorMain.cs | 12 +++++++++++- src/testhost.x86/DefaultEngineInvoker.cs | 12 +++++++++++- .../Processors/EnableDiagArgumentProcessor.cs | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/TestPlatform.sln b/TestPlatform.sln index 1fc804afa4..cd278af64a 100644 --- a/TestPlatform.sln +++ b/TestPlatform.sln @@ -815,6 +815,7 @@ Global {9EFCEFB5-253E-4DE2-8A70-821D7B8189DF} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6} {3A8080FB-9C93-45B9-8EB5-828DDC31FDF0} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6} {BFF7714C-E5A3-4EEB-B04B-5FA47F29AD03} = {020E15EA-731F-4667-95AF-226671E0C3AE} + {E344E0A2-7715-4C7F-BAF7-D64EA94CB19B} = {EE49F5DC-5835-4AE3-B3BA-8BDE0AD56330} {DD9382B5-5EC4-4B3D-BEB7-95423731AE29} = {46250E12-4CF1-4051-B4A7-80C8C06E0068} {156F8811-28BB-4EC7-87D9-434F10FB7DBE} = {46250E12-4CF1-4051-B4A7-80C8C06E0068} {A5B167ED-873A-4762-9326-5F43B8D3AFF6} = {595BE9C1-E10F-4E50-938A-E6C248D3F950} diff --git a/src/datacollector/DataCollectorMain.cs b/src/datacollector/DataCollectorMain.cs index 106cbda3c5..5e094459c9 100644 --- a/src/datacollector/DataCollectorMain.cs +++ b/src/datacollector/DataCollectorMain.cs @@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestPlatform.DataCollector using System; using System.Diagnostics; using System.Globalization; - + using System.Reflection; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces; @@ -79,6 +79,7 @@ public void Run(string[] args) // Initialize trace. EqtTrace.InitializeTrace(logFile, traceLevel); + // Log warning in case tracelevel passed in arg is invalid if (!isTraceLevelArgValid) { @@ -90,6 +91,15 @@ public void Run(string[] args) EqtTrace.DoNotInitailize = true; } + if (EqtTrace.IsVerboseEnabled) + { + var version = typeof(DataCollectorMain) + .GetTypeInfo() + .Assembly + .GetCustomAttribute()?.InformationalVersion; + EqtTrace.Verbose($"Version: { version }"); + } + SetCultureSpecifiedByUser(); EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args)); diff --git a/src/testhost.x86/DefaultEngineInvoker.cs b/src/testhost.x86/DefaultEngineInvoker.cs index 7495aa848c..6538bba96c 100644 --- a/src/testhost.x86/DefaultEngineInvoker.cs +++ b/src/testhost.x86/DefaultEngineInvoker.cs @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.TestHost using System.Collections.Generic; using System.Globalization; using System.Net; + using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestPlatform.Common; @@ -73,6 +74,15 @@ public void Invoke(IDictionary argsDictionary) { DefaultEngineInvoker.InitializeEqtTrace(argsDictionary); + if (EqtTrace.IsVerboseEnabled) + { + var version = typeof(DefaultEngineInvoker) + .GetTypeInfo() + .Assembly + .GetCustomAttribute()?.InformationalVersion; + EqtTrace.Verbose($"Version: { version }"); + } + if (EqtTrace.IsInfoEnabled) { EqtTrace.Info("DefaultEngineInvoker.Invoke: Testhost process started with args :{0}", @@ -142,7 +152,7 @@ private static RequestData GetRequestData(IDictionary argsDictio { MetricsCollection = telemetryOptedIn - ? (IMetricsCollection) new MetricsCollection() + ? (IMetricsCollection)new MetricsCollection() : new NoOpMetricsCollection(), IsTelemetryOptedIn = telemetryOptedIn }; diff --git a/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs b/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs index 2656c0105c..045e7921ed 100644 --- a/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableDiagArgumentProcessor.cs @@ -8,6 +8,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors using System.Globalization; using System.IO; using System.Linq; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.Utilities; @@ -153,6 +154,10 @@ public void Initialize(string argument) // Initialize diag logging. InitializeDiagLogging(diagFilePath, diagParameters); + + // 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}"); } ///