diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 289f105987e..5830cdc7f02 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -2,8 +2,8 @@ // Licensed under the MIT License. using System.Collections; -using System.Diagnostics; using System.Globalization; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -77,8 +77,8 @@ static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); - string assemblyPath = typeof(PSVersionInfo).Assembly.Location; - string productVersion = FileVersionInfo.GetVersionInfo(assemblyPath).ProductVersion; + Assembly currentAssembly = typeof(PSVersionInfo).Assembly; + string productVersion = currentAssembly.GetCustomAttribute().InformationalVersion; // Get 'GitCommitId' and 'PSVersion' from the 'productVersion' assembly attribute. // diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index 05b2534bc9a..6ce9dfc463d 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -22,7 +22,6 @@ Describe "Validate start of console host" -Tag CI { 'System.ComponentModel.TypeConverter.dll' 'System.Console.dll' 'System.Data.Common.dll' - 'System.Diagnostics.FileVersionInfo.dll' 'System.Diagnostics.Process.dll' 'System.Diagnostics.TraceSource.dll' 'System.Diagnostics.Tracing.dll' @@ -67,6 +66,7 @@ Describe "Validate start of console host" -Tag CI { if ($IsWindows) { $allowedAssemblies += @( 'Microsoft.PowerShell.CoreCLR.Eventing.dll' + 'System.Diagnostics.FileVersionInfo.dll' 'System.DirectoryServices.dll' 'System.Management.dll' 'System.Security.Claims.dll' @@ -76,10 +76,7 @@ Describe "Validate start of console host" -Tag CI { } else { $allowedAssemblies += @( - 'System.Collections.Immutable.dll' - 'System.IO.MemoryMappedFiles.dll' 'System.Net.Sockets.dll' - 'System.Reflection.Metadata.dll' ) }