From 7e0e6adb14fd660d685eef75d2c36cb19dd3b4c8 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Tue, 19 Sep 2017 12:12:51 +0300 Subject: [PATCH 01/18] Get 'PSVersion' from ProductVersion attribute --- .../engine/PSVersionInfo.cs | 7 ++++++- test/powershell/Host/PSVersionTable.Tests.ps1 | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 59002c5a679..6598940db37 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -45,7 +45,7 @@ internal class PSVersionInfo private static Version s_psV4Version = new Version(4, 0); private static Version s_psV5Version = new Version(5, 0); private static Version s_psV51Version = new Version(5, 1, NTVerpVars.PRODUCTBUILD, NTVerpVars.PRODUCTBUILD_QFE); - private static SemanticVersion s_psV6Version = new SemanticVersion(6, 0, 0, "beta"); + private static SemanticVersion s_psV6Version; /// /// A constant to track current PowerShell Edition @@ -57,6 +57,11 @@ static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); + string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); + + s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion); + s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; s_psVersionTable[PSGitCommitIdName] = GetCommitInfo(); diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index a9513d4f518..c1dbc5590f1 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -15,8 +15,15 @@ Describe "PSVersionTable" -Tags "CI" { $PSVersionTable.ContainsKey("OS") | Should Be True } - It "GitCommitId property should not contain an error" { - $PSVersionTable.GitCommitId | Should not match "powershell.version" + + It "PSVersion property" { + $powershellProcess=Get-Process -id $pid + $rootPath = Split-Path -Path $powershellProcess.path -Parent + $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") + $expectedVersion = $sma.VersionInfo.ProductVersion + + $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" + $PSVersionTable.PSVersion | Should BeExactly $expectedVersion } It "Should have the correct platform info" { From c3bc0b834f82e8242053634b360416a0c9b636bd Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 13:18:48 +0300 Subject: [PATCH 02/18] Replace versionTable["GitCommitId"] with PSVersionInfo.GitCommitId --- .../remoting/commands/CustomShellCommands.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index c28b7939ddf..b399d9a8270 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -132,7 +132,7 @@ function Register-PSSessionConfiguration $pluginWsmanRunAsUserPath = [System.IO.Path]::Combine(""WSMan:\localhost\Plugin"", ""$pluginName"", ""RunAsUser"") set-item -WarningAction SilentlyContinue $pluginWsmanRunAsUserPath $runAsCredential -confirm:$false }} catch {{ - + remove-item (Join-Path WSMan:\localhost\Plugin ""$pluginName"") -recurse -force write-error $_ # Do not add anymore clean up code after Write-Error, because if EA=Stop is set by user @@ -1564,7 +1564,7 @@ internal static string GetWinrmPluginShellName() Hashtable versionTable = PSVersionInfo.GetPSVersionTable(); // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. - return System.String.Concat("PowerShell.", (string)versionTable["GitCommitId"]); + return System.String.Concat("PowerShell.", PSVersionInfo.GitCommitId); } /// @@ -1577,7 +1577,7 @@ internal static string GetWinrmPluginDllPath() Hashtable versionTable = PSVersionInfo.GetPSVersionTable(); // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. - string pluginDllDirectory = System.IO.Path.Combine("%windir%\\system32\\PowerShell", (string)versionTable["GitCommitId"]); + string pluginDllDirectory = System.IO.Path.Combine("%windir%\\system32\\PowerShell", PSVersionInfo.GitCommitId); return System.IO.Path.Combine(pluginDllDirectory, RemotingConstants.PSPluginDLLName); } @@ -2555,7 +2555,7 @@ function Unregister-PSSessionConfiguration return }} }} - + $shellsFound++ $shouldProcessTargetString = $targetTemplate -f $_.Name @@ -2779,12 +2779,12 @@ function ExtractPluginProperties([string]$pluginDir, $objectToWriteTo) }} Get-Details $pluginDir $h - + # Workflow is not supported in PowerShell Core. Attempting to load the # assembly results in a FileNotFoundException. if (![System.Management.Automation.Platform]::IsCoreCLR -AND $h[""AssemblyName""] -eq ""Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"") {{ - + $serviceCore = [Reflection.Assembly]::Load(""Microsoft.Powershell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"") if ($null -ne $serviceCore) {{ @@ -4967,7 +4967,7 @@ function Enable-PSRemoting }} }} }} - + # remove the 'network deny all' tag Get-PSSessionConfiguration -Force:$Force | ForEach-Object {{ $sddl = $null From 16fe5da40b2fbc4d508ce3a8470f11584ad8a67c Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 13:19:11 +0300 Subject: [PATCH 03/18] Split GitCommitId on formatted and non-formatted --- PowerShell.Common.props | 3 ++ .../host/msh/ManagedEntrance.cs | 2 +- .../engine/PSVersionInfo.cs | 34 +++++++++++++++---- test/powershell/Host/PSVersionTable.Tests.ps1 | 4 ++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 540ff72895c..d71b4e03e36 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -31,6 +31,9 @@ $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value) $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value) + $(PSCoreBuildVersion) SHA: $(PSCoreCommitSHA) $(PSCoreBuildVersion) Commits: $(PSCoreAdditionalCommits) SHA: $(PSCoreCommitSHA) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs index 380fa7e0d41..7732d98d30c 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs @@ -97,7 +97,7 @@ public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray try { var banner = ManagedEntranceStrings.ShellBannerNonWindowsPowerShell; - var formattedBanner = string.Format(CultureInfo.InvariantCulture, banner, PSVersionInfo.GitCommitId); + var formattedBanner = string.Format(CultureInfo.InvariantCulture, banner, PSVersionInfo.FormattedGitCommitId); exitCode = Microsoft.PowerShell.ConsoleShell.Start( configuration, formattedBanner, diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 6598940db37..cfc48fc7d6f 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -20,7 +20,7 @@ internal class PSVersionInfo internal const string PSRemotingProtocolVersionName = "PSRemotingProtocolVersion"; internal const string PSVersionName = "PSVersion"; internal const string PSEditionName = "PSEdition"; - internal const string PSGitCommitIdName = "GitCommitId"; + internal const string PSFormattedGitCommitIdName = "GitCommitId"; internal const string PSCompatibleVersionsName = "PSCompatibleVersions"; internal const string PSPlatformName = "Platform"; internal const string PSOSName = "OS"; @@ -28,6 +28,13 @@ internal class PSVersionInfo internal const string WSManStackVersionName = "WSManStackVersion"; private static PSVersionHashTable s_psVersionTable = null; + /// + /// The constant contains a raw git commit version. + /// 'git describe --abbrev=60 --long' + /// Ex.: '6.0.0-beta.7-29-52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c' + /// + private static string s_rawGitCommitId; + /// /// A constant to track current PowerShell Version. /// @@ -57,14 +64,21 @@ static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); - string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; - FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); + // Get '6.0.0-beta.7 Commits: 29 SHA: 52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. + // The formatted string is displayed to users in '$PSVersionTable' and PowerShell banner. + string assemblyPath = typeof(PSVersionInfo).Assembly.Location; + string formattedGitCommitId = FileVersionInfo.GetVersionInfo(assemblyPath).ProductVersion; + s_psVersionTable[PSFormattedGitCommitIdName] = formattedGitCommitId; - s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion); + // Convert to '6.0.0-beta.7-29-52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. + // The raw git commit version string is widely used internally. + s_rawGitCommitId = "v" + formattedGitCommitId.Replace(" Commits: ", "-").Replace(" SHA: ", "-"); + + // Use a short version '6.0.0-beta.7'. + s_psV6Version = new SemanticVersion(formattedGitCommitId.Substring(0, formattedGitCommitId.IndexOf(' '))); s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; - s_psVersionTable[PSGitCommitIdName] = GetCommitInfo(); s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; @@ -152,7 +166,15 @@ internal static string GitCommitId { get { - return (string)GetPSVersionTable()[PSGitCommitIdName]; + return s_rawGitCommitId; + } + } + + internal static string FormattedGitCommitId + { + get + { + return (string)GetPSVersionTable()[PSFormattedGitCommitIdName]; } } diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index c1dbc5590f1..7bb0d8fa24f 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -20,7 +20,9 @@ Describe "PSVersionTable" -Tags "CI" { $powershellProcess=Get-Process -id $pid $rootPath = Split-Path -Path $powershellProcess.path -Parent $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") - $expectedVersion = $sma.VersionInfo.ProductVersion + # Convert '6.0.0-beta.7 Commits: 29 SHA: 52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c' + # to '6.0.0-beta.7' + $expectedVersion = ($sma.VersionInfo.ProductVersion -split " ")[0] $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" $PSVersionTable.PSVersion | Should BeExactly $expectedVersion From 04ef45036a5ecf9786c1f4c07762e18801ee6023 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 13:25:24 +0300 Subject: [PATCH 04/18] Remove 'powershell.version' file --- build.psm1 | 8 -------- .../engine/PSVersionInfo.cs | 14 -------------- src/powershell-unix/powershell-unix.csproj | 2 +- src/powershell-win-core/powershell-win-core.csproj | 2 +- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/build.psm1 b/build.psm1 index ed083524322..3d3000b05fc 100644 --- a/build.psm1 +++ b/build.psm1 @@ -393,14 +393,6 @@ function Start-PSBuild { } } - # save git commit id to file for PowerShell to include in PSVersionTable - $gitCommitId = $ReleaseTag - if (-not $gitCommitId) { - # if ReleaseTag is not specified, use 'git describe' to get the commit id - $gitCommitId = Get-PSCommitId -WarningAction SilentlyContinue - } - $gitCommitId > "$psscriptroot/powershell.version" - # create the telemetry flag file $null = new-item -force -type file "$psscriptroot/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY" diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index cfc48fc7d6f..fa8646c0534 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -100,20 +100,6 @@ internal static Hashtable GetPSVersionTableForDownLevel() return result; } - // Get the commit id from the powershell.version file. If the powershell.version file doesn't exist, use the string "N/A" - internal static string GetCommitInfo() - { - try - { - string assemblyPath = IO.Path.GetDirectoryName(typeof(PSVersionInfo).GetTypeInfo().Assembly.Location); - return (IO.File.ReadAllLines(IO.Path.Combine(assemblyPath, "powershell.version"))[0]); - } - catch (Exception e) - { - return e.Message; - } - } - #region Private helper methods // Gets the current WSMan stack version from the registry. diff --git a/src/powershell-unix/powershell-unix.csproj b/src/powershell-unix/powershell-unix.csproj index bc83fafcae2..d52667fdb42 100644 --- a/src/powershell-unix/powershell-unix.csproj +++ b/src/powershell-unix/powershell-unix.csproj @@ -16,7 +16,7 @@ PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj index 3d19fec1cd0..ce061e85929 100644 --- a/src/powershell-win-core/powershell-win-core.csproj +++ b/src/powershell-win-core/powershell-win-core.csproj @@ -19,7 +19,7 @@ PreserveNewest PreserveNewest - + PreserveNewest PreserveNewest From 8c29037d46b48f72c1692083ac43361cec82da49 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 16:41:17 +0300 Subject: [PATCH 05/18] Fix Enable-PSRemoting --- .../engine/remoting/commands/CustomShellCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index b399d9a8270..ddcec1bbaf6 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -4874,7 +4874,7 @@ function Enable-PSRemoting # Section 1: # Move pwrshplugin.dll from $PSHOME to the endpoint directory # - $pluginInstallPath = Join-Path ""$env:WINDIR\System32\PowerShell"" $psversiontable.GitCommitId + $pluginInstallPath = Join-Path ""$env:WINDIR\System32\PowerShell"" (""v"" + $psversiontable.GitCommitId -replace "" Commits: "", ""-"" -replace "" SHA: "", ""-"") if (!(Test-Path $pluginInstallPath)) {{ $resolvedPluginInstallPath = New-Item -Type Directory -Path $pluginInstallPath From 38b9827cac0c1c2364e1056c4ec26e1ff9aafd38 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 17:06:26 +0300 Subject: [PATCH 06/18] Fix test --- .../Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index 1ce879f0295..07446bb539b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -15,7 +15,7 @@ try # if ($IsNotSkipped) { - $endpointName = "PowerShell.$($psversiontable.GitCommitId)" + $endpointName = "PowerShell.v$($psversiontable.GitCommitId)" -replace " Commits: ", "-" -replace " SHA: ", "-" $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue From b8a83fa028619aacf32bbc0f804ac7112f072d6c Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 20 Sep 2017 17:22:17 +0300 Subject: [PATCH 07/18] Add test --- test/powershell/Host/PSVersionTable.Tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index 7bb0d8fa24f..accc3f6113d 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -28,6 +28,11 @@ Describe "PSVersionTable" -Tags "CI" { $PSVersionTable.PSVersion | Should BeExactly $expectedVersion } + It "GitCommitId property" { + $PSVersionTable.GitCommitId | Should BeOfType "System.String" + { [System.Management.Automation.SemanticVersion]::Parse($PSVersionTable.GitCommitId) } | Should Not Throw + } + It "Should have the correct platform info" { $platform = [String][System.Environment]::OSVersion.Platform [String]$PSVersionTable["Platform"] | Should Be $platform From 0a15f55e114112af08c41247ba91e628c3da0490 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 11:57:26 +0300 Subject: [PATCH 08/18] Revert "Fix test" This reverts commit 8e4b02c00c298e26fc6cac8015a543fb080dc89b. --- .../Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index 07446bb539b..1ce879f0295 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -15,7 +15,7 @@ try # if ($IsNotSkipped) { - $endpointName = "PowerShell.v$($psversiontable.GitCommitId)" -replace " Commits: ", "-" -replace " SHA: ", "-" + $endpointName = "PowerShell.$($psversiontable.GitCommitId)" $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue From ce1ed51747d60da7ee1f3a421862234a4b511402 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 11:57:40 +0300 Subject: [PATCH 09/18] Revert "Fix Enable-PSRemoting" This reverts commit d3d93f1197d8b00747b2ae654456666cae06836e. --- .../engine/remoting/commands/CustomShellCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index ddcec1bbaf6..b399d9a8270 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -4874,7 +4874,7 @@ function Enable-PSRemoting # Section 1: # Move pwrshplugin.dll from $PSHOME to the endpoint directory # - $pluginInstallPath = Join-Path ""$env:WINDIR\System32\PowerShell"" (""v"" + $psversiontable.GitCommitId -replace "" Commits: "", ""-"" -replace "" SHA: "", ""-"") + $pluginInstallPath = Join-Path ""$env:WINDIR\System32\PowerShell"" $psversiontable.GitCommitId if (!(Test-Path $pluginInstallPath)) {{ $resolvedPluginInstallPath = New-Item -Type Directory -Path $pluginInstallPath From 5ec4f94f624717b355f8dd24a95cc1df8923a3f3 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 11:58:46 +0300 Subject: [PATCH 10/18] Revert "Split GitCommitId on formatted and non-formatted" This reverts commit 089e22b9146c89ee9430dcf21594e80c865f3eaf. --- PowerShell.Common.props | 3 -- .../host/msh/ManagedEntrance.cs | 2 +- .../engine/PSVersionInfo.cs | 34 ++++--------------- test/powershell/Host/PSVersionTable.Tests.ps1 | 4 +-- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/PowerShell.Common.props b/PowerShell.Common.props index d71b4e03e36..540ff72895c 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -31,9 +31,6 @@ $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value) $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value) - $(PSCoreBuildVersion) SHA: $(PSCoreCommitSHA) $(PSCoreBuildVersion) Commits: $(PSCoreAdditionalCommits) SHA: $(PSCoreCommitSHA) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs index 7732d98d30c..380fa7e0d41 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs @@ -97,7 +97,7 @@ public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray try { var banner = ManagedEntranceStrings.ShellBannerNonWindowsPowerShell; - var formattedBanner = string.Format(CultureInfo.InvariantCulture, banner, PSVersionInfo.FormattedGitCommitId); + var formattedBanner = string.Format(CultureInfo.InvariantCulture, banner, PSVersionInfo.GitCommitId); exitCode = Microsoft.PowerShell.ConsoleShell.Start( configuration, formattedBanner, diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index fa8646c0534..641f7a93a14 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -20,7 +20,7 @@ internal class PSVersionInfo internal const string PSRemotingProtocolVersionName = "PSRemotingProtocolVersion"; internal const string PSVersionName = "PSVersion"; internal const string PSEditionName = "PSEdition"; - internal const string PSFormattedGitCommitIdName = "GitCommitId"; + internal const string PSGitCommitIdName = "GitCommitId"; internal const string PSCompatibleVersionsName = "PSCompatibleVersions"; internal const string PSPlatformName = "Platform"; internal const string PSOSName = "OS"; @@ -28,13 +28,6 @@ internal class PSVersionInfo internal const string WSManStackVersionName = "WSManStackVersion"; private static PSVersionHashTable s_psVersionTable = null; - /// - /// The constant contains a raw git commit version. - /// 'git describe --abbrev=60 --long' - /// Ex.: '6.0.0-beta.7-29-52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c' - /// - private static string s_rawGitCommitId; - /// /// A constant to track current PowerShell Version. /// @@ -64,21 +57,14 @@ static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); - // Get '6.0.0-beta.7 Commits: 29 SHA: 52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. - // The formatted string is displayed to users in '$PSVersionTable' and PowerShell banner. - string assemblyPath = typeof(PSVersionInfo).Assembly.Location; - string formattedGitCommitId = FileVersionInfo.GetVersionInfo(assemblyPath).ProductVersion; - s_psVersionTable[PSFormattedGitCommitIdName] = formattedGitCommitId; + string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); - // Convert to '6.0.0-beta.7-29-52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. - // The raw git commit version string is widely used internally. - s_rawGitCommitId = "v" + formattedGitCommitId.Replace(" Commits: ", "-").Replace(" SHA: ", "-"); - - // Use a short version '6.0.0-beta.7'. - s_psV6Version = new SemanticVersion(formattedGitCommitId.Substring(0, formattedGitCommitId.IndexOf(' '))); + s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion); s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; + s_psVersionTable[PSGitCommitIdName] = GetCommitInfo(); s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; @@ -152,15 +138,7 @@ internal static string GitCommitId { get { - return s_rawGitCommitId; - } - } - - internal static string FormattedGitCommitId - { - get - { - return (string)GetPSVersionTable()[PSFormattedGitCommitIdName]; + return (string)GetPSVersionTable()[PSGitCommitIdName]; } } diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index accc3f6113d..edebef388d6 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -20,9 +20,7 @@ Describe "PSVersionTable" -Tags "CI" { $powershellProcess=Get-Process -id $pid $rootPath = Split-Path -Path $powershellProcess.path -Parent $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") - # Convert '6.0.0-beta.7 Commits: 29 SHA: 52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c' - # to '6.0.0-beta.7' - $expectedVersion = ($sma.VersionInfo.ProductVersion -split " ")[0] + $expectedVersion = $sma.VersionInfo.ProductVersion $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" $PSVersionTable.PSVersion | Should BeExactly $expectedVersion From b57f457d8361aa3c3575d5310cfd812706445dfd Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 12:50:23 +0300 Subject: [PATCH 11/18] Improve tests --- test/powershell/Host/PSVersionTable.Tests.ps1 | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index edebef388d6..79799f7ea9d 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -1,4 +1,14 @@ Describe "PSVersionTable" -Tags "CI" { + + BeforeAll { + $powershellProcess=Get-Process -id $pid + $rootPath = Split-Path -Path $powershellProcess.path -Parent + $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") + $formattedVersion = $sma.VersionInfo.ProductVersion + $rawGitCommitId = "v" + $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") + $expectedVersion = ($formattedVersion -split " ")[0] + } + It "Should have version table entries" { $PSVersionTable.Count | Should Be 9 } @@ -17,30 +27,27 @@ Describe "PSVersionTable" -Tags "CI" { } It "PSVersion property" { - $powershellProcess=Get-Process -id $pid - $rootPath = Split-Path -Path $powershellProcess.path -Parent - $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") - $expectedVersion = $sma.VersionInfo.ProductVersion - $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" $PSVersionTable.PSVersion | Should BeExactly $expectedVersion + $PSVersionTable.PSVersion.Major | Should Be 6 } It "GitCommitId property" { $PSVersionTable.GitCommitId | Should BeOfType "System.String" - { [System.Management.Automation.SemanticVersion]::Parse($PSVersionTable.GitCommitId) } | Should Not Throw + [regex]::IsMatch($PSVersionTable.GitCommitId, "^v(\d+\.\d+\.\d+)-(.+)-(\d+)-g(.+)") | Should Be $true + $PSVersionTable.GitCommitId | Should BeExactly $rawGitCommitId } It "Should have the correct platform info" { $platform = [String][System.Environment]::OSVersion.Platform - [String]$PSVersionTable["Platform"] | Should Be $platform + [String]$PSVersionTable["Platform"] | Should Be $platform } It "Should have the correct OS info" { if ($IsCoreCLR) { $OSDescription = [String][System.Runtime.InteropServices.RuntimeInformation]::OSDescription - [String]$PSVersionTable["OS"] | Should Be $OSDescription + [String]$PSVersionTable["OS"] | Should Be $OSDescription } else { From b85ca57111ce2ba8fc6148fd096f0e4fb33ffb40 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 12:50:55 +0300 Subject: [PATCH 12/18] Reconstruct raw GitCommitId --- src/System.Management.Automation/engine/PSVersionInfo.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 641f7a93a14..2a0c7dabd44 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -60,11 +60,15 @@ static PSVersionInfo() string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); - s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion); + // Convert to '6.0.0-beta.7-29-g52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. + // The raw git commit version string is widely used internally. + string rawGitCommitId = "v" + fileVersionInfo.ProductVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + + s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion.Substring(0, fileVersionInfo.ProductVersion.IndexOf(' '))); s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; - s_psVersionTable[PSGitCommitIdName] = GetCommitInfo(); + s_psVersionTable[PSGitCommitIdName] = rawGitCommitId; s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; From fbc35bd3746585d52adf47f71b1b6d774d9e66ce Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 21 Sep 2017 12:51:48 +0300 Subject: [PATCH 13/18] Minor fixes --- .gitignore | 3 --- PowerShell.Common.props | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 59a05754fc8..06a7882365a 100644 --- a/.gitignore +++ b/.gitignore @@ -43,9 +43,6 @@ dotnet-uninstall-debian-packages.sh *.pkg *.nupkg -# ignore the version file as it is generated at build time -powershell.version - # ignore the telemetry semaphore file DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY diff --git a/PowerShell.Common.props b/PowerShell.Common.props index 540ff72895c..ccbbd1ea40f 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -31,6 +31,9 @@ $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value) $([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value) + $(PSCoreBuildVersion) SHA: $(PSCoreCommitSHA) $(PSCoreBuildVersion) Commits: $(PSCoreAdditionalCommits) SHA: $(PSCoreCommitSHA) From 9f93ebe69b0339a044fdda1ebb39f72af0c8984c Mon Sep 17 00:00:00 2001 From: iSazonov Date: Fri, 22 Sep 2017 07:21:41 +0300 Subject: [PATCH 14/18] Remove unused code --- .../engine/remoting/commands/CustomShellCommands.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index b399d9a8270..5178faa489c 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1561,7 +1561,6 @@ internal static string GetRunAsVirtualAccountGroupsString(string[] groups) internal static string GetWinrmPluginShellName() { // PowerShell Core uses a versioned directory to hold the plugin - Hashtable versionTable = PSVersionInfo.GetPSVersionTable(); // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. return System.String.Concat("PowerShell.", PSVersionInfo.GitCommitId); @@ -1574,7 +1573,6 @@ internal static string GetWinrmPluginShellName() internal static string GetWinrmPluginDllPath() { // PowerShell Core uses its versioned directory instead of system32 - Hashtable versionTable = PSVersionInfo.GetPSVersionTable(); // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. string pluginDllDirectory = System.IO.Path.Combine("%windir%\\system32\\PowerShell", PSVersionInfo.GitCommitId); From 9f740fa05b63c2bbb550662640e2a40506614ee9 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Fri, 22 Sep 2017 07:24:01 +0300 Subject: [PATCH 15/18] Correct comment and add local variable --- .../engine/PSVersionInfo.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 2a0c7dabd44..1b5c678dd8a 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -57,14 +57,15 @@ static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); - string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location; - FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); + string assemblyPath = typeof(PSVersionInfo).Assembly.Location; + string productVersion = FileVersionInfo.GetVersionInfo(assemblyPath).ProductVersion; - // Convert to '6.0.0-beta.7-29-g52c6bfe1eae24dbaa1a162bffb3754ba3fdc1f4c'. - // The raw git commit version string is widely used internally. - string rawGitCommitId = "v" + fileVersionInfo.ProductVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + // Get 'ProductVersion' of the assembly. The product version string can be one of the following format examples: + // when powershell is built from a commit -- '6.0.0-beta.7 Commits: 29 SHA: 52c6b...' + // when powershell is built from a release tag -- '6.0.0-beta.7 SHA: f1ec9...' + string rawGitCommitId = "v" + productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); - s_psV6Version = new SemanticVersion(fileVersionInfo.ProductVersion.Substring(0, fileVersionInfo.ProductVersion.IndexOf(' '))); + s_psV6Version = new SemanticVersion(productVersion.Substring(0, productVersion.IndexOf(' '))); s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; From ad92e3cd1f730dbab033758026a13a33613e7b9f Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 27 Sep 2017 09:35:41 +0300 Subject: [PATCH 16/18] Fix GitCommitId, comments and tests --- .../engine/PSVersionInfo.cs | 29 +++++++++++++++---- test/powershell/Host/PSVersionTable.Tests.ps1 | 25 +++++++++++++--- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 1b5c678dd8a..c1403d27511 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -60,12 +60,31 @@ static PSVersionInfo() string assemblyPath = typeof(PSVersionInfo).Assembly.Location; string productVersion = FileVersionInfo.GetVersionInfo(assemblyPath).ProductVersion; - // Get 'ProductVersion' of the assembly. The product version string can be one of the following format examples: - // when powershell is built from a commit -- '6.0.0-beta.7 Commits: 29 SHA: 52c6b...' - // when powershell is built from a release tag -- '6.0.0-beta.7 SHA: f1ec9...' - string rawGitCommitId = "v" + productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + // Get 'GitCommitId' and 'PSVersion' from the 'productVersion' assembly attribute. + // + // The strings can be one of the following format examples: + // when powershell is built from a commit: + // productVersion = 6.0.0-beta.7 Commits: 29 SHA: 52c6b...' convert to GitCommitId = '6.0.0-beta.7-29-g52c6b...' + // PSVersion = '6.0.0-beta.7' + // when powershell is built from a release tag: + // productVersion = '6.0.0-beta.7 SHA: f1ec9...' convert to GitCommitId = '6.0.0-beta.7' + // PSVersion = '6.0.0-beta.7' + // when powershell is built from a release tag for RTM: + // productVersion = '6.0.0 SHA: f1ec9...' convert to GitCommitId = '6.0.0' + // PSVersion = '6.0.0' + string rawGitCommitId; + string mainVersion = productVersion.Substring(0, productVersion.IndexOf(' ')); - s_psV6Version = new SemanticVersion(productVersion.Substring(0, productVersion.IndexOf(' '))); + if (productVersion.Contains(" Commits: ")) + { + rawGitCommitId = "v" + productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + } + else + { + rawGitCommitId = "v" + mainVersion; + } + + s_psV6Version = new SemanticVersion(mainVersion); s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index 79799f7ea9d..fd5572507f6 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -5,8 +5,23 @@ Describe "PSVersionTable" -Tags "CI" { $rootPath = Split-Path -Path $powershellProcess.path -Parent $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") $formattedVersion = $sma.VersionInfo.ProductVersion - $rawGitCommitId = "v" + $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") - $expectedVersion = ($formattedVersion -split " ")[0] + + $mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?" + $fullVersionPattern = "^v(\d+\.\d+\.\d+)-(.+)-(\d+)-g(.+)$" + + $expectedPSVersion = ($formattedVersion -split " ")[0] + $expectedVersionPattern = "^$mainVersionPattern$" + + if ($formattedVersion.Contains(" Commits: ")) + { + $rawGitCommitId = "v" + $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") + $expectedGitCommitIdPattern = $fullVersionPattern + $unexpectectGitCommitIdPattern = "qwerty" + } else { + $rawGitCommitId = "v" + ($formattedVersion -split " SHA: ")[0] + $expectedGitCommitIdPattern = "^v$mainVersionPattern$" + $unexpectectGitCommitIdPattern = $fullVersionPattern + } } It "Should have version table entries" { @@ -28,13 +43,15 @@ Describe "PSVersionTable" -Tags "CI" { It "PSVersion property" { $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" - $PSVersionTable.PSVersion | Should BeExactly $expectedVersion + $PSVersionTable.PSVersion | Should BeExactly $expectedPSVersion + $PSVersionTable.PSVersion | Should Match $expectedVersionPattern $PSVersionTable.PSVersion.Major | Should Be 6 } It "GitCommitId property" { $PSVersionTable.GitCommitId | Should BeOfType "System.String" - [regex]::IsMatch($PSVersionTable.GitCommitId, "^v(\d+\.\d+\.\d+)-(.+)-(\d+)-g(.+)") | Should Be $true + $PSVersionTable.GitCommitId | Should Match $expectedGitCommitIdPattern + $PSVersionTable.GitCommitId | Should Not Match $unexpectectGitCommitIdPattern $PSVersionTable.GitCommitId | Should BeExactly $rawGitCommitId } From f469c0e26c15e4e0a3286d96c91175bc4f62da41 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 27 Sep 2017 12:44:03 -0700 Subject: [PATCH 17/18] Minor fixes to the comments --- .../engine/PSVersionInfo.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index c1403d27511..07af6f347b9 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -64,14 +64,14 @@ static PSVersionInfo() // // The strings can be one of the following format examples: // when powershell is built from a commit: - // productVersion = 6.0.0-beta.7 Commits: 29 SHA: 52c6b...' convert to GitCommitId = '6.0.0-beta.7-29-g52c6b...' - // PSVersion = '6.0.0-beta.7' + // productVersion = '6.0.0-beta.7 Commits: 29 SHA: 52c6b...' convert to GitCommitId = 'v6.0.0-beta.7-29-g52c6b...' + // PSVersion = '6.0.0-beta.7' // when powershell is built from a release tag: - // productVersion = '6.0.0-beta.7 SHA: f1ec9...' convert to GitCommitId = '6.0.0-beta.7' - // PSVersion = '6.0.0-beta.7' + // productVersion = '6.0.0-beta.7 SHA: f1ec9...' convert to GitCommitId = 'v6.0.0-beta.7' + // PSVersion = '6.0.0-beta.7' // when powershell is built from a release tag for RTM: - // productVersion = '6.0.0 SHA: f1ec9...' convert to GitCommitId = '6.0.0' - // PSVersion = '6.0.0' + // productVersion = '6.0.0 SHA: f1ec9...' convert to GitCommitId = 'v6.0.0' + // PSVersion = '6.0.0' string rawGitCommitId; string mainVersion = productVersion.Substring(0, productVersion.IndexOf(' ')); @@ -841,4 +841,4 @@ internal Exception GetVersionParseException() } } } -} \ No newline at end of file +} From 2dbf5680607a4b9f11ab697f8d7b6a2711811be9 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 28 Sep 2017 08:34:35 +0300 Subject: [PATCH 18/18] Use $PSHome in tests --- test/powershell/Host/PSVersionTable.Tests.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index fd5572507f6..d9ae1f863a4 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -1,9 +1,7 @@ Describe "PSVersionTable" -Tags "CI" { BeforeAll { - $powershellProcess=Get-Process -id $pid - $rootPath = Split-Path -Path $powershellProcess.path -Parent - $sma = Get-Item (Join-Path $rootPath "System.Management.Automation.dll") + $sma = Get-Item (Join-Path $PSHome "System.Management.Automation.dll") $formattedVersion = $sma.VersionInfo.ProductVersion $mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?"