Get PowerShell version in PSVersionInfo using assembly attribute instead of FileVersionInfo (#14332)

This commit is contained in:
Francesco Saltori
2020-12-11 17:12:10 -08:00
committed by GitHub
parent d487537453
commit ea2da20a23
2 changed files with 4 additions and 7 deletions
@@ -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 @@ namespace System.Management.Automation
{
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<AssemblyInformationalVersionAttribute>().InformationalVersion;
// Get 'GitCommitId' and 'PSVersion' from the 'productVersion' assembly attribute.
//
+1 -4
View File
@@ -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'
)
}