diff --git a/src/Grpc/test/InteropTests/InteropTests.csproj b/src/Grpc/test/InteropTests/InteropTests.csproj index 24d479432b09..bcbd1fc4b6ab 100644 --- a/src/Grpc/test/InteropTests/InteropTests.csproj +++ b/src/Grpc/test/InteropTests/InteropTests.csproj @@ -3,9 +3,6 @@ true $(DefaultNetCoreTargetFramework) - - - false diff --git a/src/Grpc/test/testassets/InteropClient/InteropClient.cs b/src/Grpc/test/testassets/InteropClient/InteropClient.cs index d6b47ab24139..91ce76153820 100644 --- a/src/Grpc/test/testassets/InteropClient/InteropClient.cs +++ b/src/Grpc/test/testassets/InteropClient/InteropClient.cs @@ -29,7 +29,6 @@ using Google.Protobuf; using Grpc.Auth; using Grpc.Core; -using Grpc.Core.Utils; using Grpc.Net.Client; using Grpc.Testing; using Microsoft.Extensions.DependencyInjection; @@ -96,11 +95,12 @@ private InteropClient(ClientOptions options) var services = new ServiceCollection(); services.AddLogging(configure => { - configure.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); - configure.AddSimpleConsole(loggerOptions => + configure.SetMinimumLevel(LogLevel.Trace); + configure.AddConsole(loggerOptions => { +#pragma warning disable CS0618 // Type or member is obsolete loggerOptions.IncludeScopes = true; - loggerOptions.DisableColors = true; +#pragma warning restore CS0618 // Type or member is obsolete }); }); diff --git a/src/Grpc/test/testassets/InteropClient/Program.cs b/src/Grpc/test/testassets/InteropClient/Program.cs index 3fc3d9d9757d..52eee5640a3a 100644 --- a/src/Grpc/test/testassets/InteropClient/Program.cs +++ b/src/Grpc/test/testassets/InteropClient/Program.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Reflection; namespace InteropTestsClient { @@ -26,6 +27,9 @@ public static void Main(string[] args) { Console.WriteLine("Application started."); + var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute()?.InformationalVersion ?? "Unknown"; + Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}"); + InteropClient.Run(args); } } diff --git a/src/Grpc/test/testassets/InteropWebsite/Program.cs b/src/Grpc/test/testassets/InteropWebsite/Program.cs index 3efd0d647c91..e160254f5d7f 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Program.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Program.cs @@ -37,7 +37,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(builder => { - builder.AddSimpleConsole(o => o.DisableColors = true); + builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Trace); }) .ConfigureWebHostDefaults(webBuilder => diff --git a/src/Grpc/test/testassets/InteropWebsite/Startup.cs b/src/Grpc/test/testassets/InteropWebsite/Startup.cs index 4715d1fbbca4..6f335d6c0590 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Startup.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Startup.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Reflection; using Grpc.Testing; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; @@ -37,7 +38,13 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicationLifetime) { // Required to notify test infrastructure that it can begin tests - applicationLifetime.ApplicationStarted.Register(() => Console.WriteLine("Application started.")); + applicationLifetime.ApplicationStarted.Register(() => + { + Console.WriteLine("Application started."); + + var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute()?.InformationalVersion ?? "Unknown"; + Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}"); + }); app.UseRouting(); app.UseEndpoints(endpoints => diff --git a/src/Shared/Process/ProcessEx.cs b/src/Shared/Process/ProcessEx.cs index ad7d06b1ede3..e263abb6a295 100644 --- a/src/Shared/Process/ProcessEx.cs +++ b/src/Shared/Process/ProcessEx.cs @@ -218,8 +218,8 @@ public void WaitForExit(bool assertSuccess, TimeSpan? timeSpan = null) private static string GetNugetPackagesRestorePath() => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_RESTORE"))) ? typeof(ProcessEx).Assembly .GetCustomAttributes() - .First(attribute => attribute.Key == "TestPackageRestorePath") - .Value + .FirstOrDefault(attribute => attribute.Key == "TestPackageRestorePath") + ?.Value : Environment.GetEnvironmentVariable("NUGET_RESTORE"); public void Dispose()