diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 335cd678c05..e6d167f669d 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -78,11 +78,11 @@ static PSVersionInfo() if (productVersion.Contains(" Commits: ")) { - rawGitCommitId = "v" + productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + rawGitCommitId = productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); } else { - rawGitCommitId = "v" + mainVersion; + rawGitCommitId = mainVersion; } s_psV6Version = new SemanticVersion(mainVersion); diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 51a7c940f62..c6570206c14 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1517,8 +1517,6 @@ internal static string GetRunAsVirtualAccountGroupsString(string[] groups) internal static string GetWinrmPluginShellName() { // PowerShell Core uses a versioned directory to hold the plugin - // 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); } @@ -1529,8 +1527,6 @@ internal static string GetWinrmPluginShellName() internal static string GetWinrmPluginDllPath() { // PowerShell Core uses its versioned directory instead of system32 - // 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); return System.IO.Path.Combine(pluginDllDirectory, RemotingConstants.PSPluginDLLName); } @@ -4889,6 +4885,12 @@ function Enable-PSRemoting if ($dotPos -ne -1) {{ $powershellVersionMajor = $powershellVersionMajor.Substring(0, $dotPos) }} + # If we are running a Preview version, we don't want to clobber the generic PowerShell.6 endpoint + # but instead create a PowerShell.6-Preview endpoint + if ($PSVersionTable.PSVersion.PreReleaseLabel) + {{ + $powershellVersionMajor += ""-preview"" + }} Register-EndpointIfNotPresent -Name (""PowerShell."" + $powershellVersionMajor) $Force $queryForRegisterDefault $captionForRegisterDefault # PowerShell Workflow and WOW are not supported for PowerShell Core diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 91400a5b122..d4672483476 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -674,7 +674,7 @@ Describe "Pwsh exe resources tests" -Tag CI { It "Resource strings are embedded in the executable" -Skip:(!$IsWindows) { $pwsh = Get-Item -Path "$PSHOME\pwsh.exe" $pwsh.VersionInfo.FileVersion | Should -BeExactly $PSVersionTable.PSVersion.ToString().Split("-")[0] - "v" + $pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId + $pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell Core 6" } diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index c3fc1ab2f6c..c1e0d5ef837 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -7,19 +7,19 @@ Describe "PSVersionTable" -Tags "CI" { $formattedVersion = $sma.VersionInfo.ProductVersion $mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?" - $fullVersionPattern = "^v(\d+\.\d+\.\d+)(-.+)?-(\d+)-g(.+)$" + $fullVersionPattern = "^(\d+\.\d+\.\d+)(-.+)?-(\d+)-g(.+)$" $expectedPSVersion = ($formattedVersion -split " ")[0] $expectedVersionPattern = "^$mainVersionPattern$" if ($formattedVersion.Contains(" Commits: ")) { - $rawGitCommitId = "v" + $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") + $rawGitCommitId = $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") $expectedGitCommitIdPattern = $fullVersionPattern $unexpectectGitCommitIdPattern = "qwerty" } else { - $rawGitCommitId = "v" + ($formattedVersion -split " SHA: ")[0] - $expectedGitCommitIdPattern = "^v$mainVersionPattern$" + $rawGitCommitId = ($formattedVersion -split " SHA: ")[0] + $expectedGitCommitIdPattern = "^$mainVersionPattern$" $unexpectectGitCommitIdPattern = $fullVersionPattern } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index beb597f9f3e..31669f45525 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -104,13 +104,13 @@ try # Create new Config File function CreateTestConfigFile { - $TestConfigFileLoc = join-path $TestDrive "Remoting" + $TestConfigFileLoc = Join-Path $TestDrive "Remoting" if(-not (Test-path $TestConfigFileLoc)) { $null = New-Item -Path $TestConfigFileLoc -ItemType Directory -Force -ErrorAction Stop } - $TestConfigFile = join-path $TestConfigFileLoc "TestConfigFile.pssc" + $TestConfigFile = Join-Path $TestConfigFileLoc "TestConfigFile.pssc" $null = New-PSSessionConfigurationFile -Path $TestConfigFile -SessionType Default return $TestConfigFile @@ -366,7 +366,7 @@ try `$script:testvariable = "testValue" "@ - $TestScript = join-path $script:TestDir "StartupTestScript.ps1" + $TestScript = Join-Path $script:TestDir "StartupTestScript.ps1" $null = Set-Content -path $TestScript -Value $ScriptContent return $TestScript @@ -375,7 +375,7 @@ try # Create new Config File function CreateTestConfigFile { - $TestConfigFile = join-path $script:TestDir "TestConfigFile.pssc" + $TestConfigFile = Join-Path $script:TestDir "TestConfigFile.pssc" $null = New-PSSessionConfigurationFile -Path $TestConfigFile -SessionType Default return $TestConfigFile } @@ -394,7 +394,7 @@ Export-ModuleMember IsTestModuleImported $null = New-Item -Path $TestModuleFileLoc -ItemType Directory -Force -ErrorAction Stop } - $TestModuleFile = join-path $TestModuleFileLoc "TestModule.psm1" + $TestModuleFile = Join-Path $TestModuleFileLoc "TestModule.psm1" $null = Set-Content -path $TestModuleFile -Value $ScriptContent return $TestModuleFile @@ -424,21 +424,21 @@ namespace PowershellTestConfigNamespace } } "@ - $script:SourceFile = join-path $script:TestAssemblyDir "PowershellTestConfig.cs" + $script:SourceFile = Join-Path $script:TestAssemblyDir "PowershellTestConfig.cs" $PscConfigDef | out-file $script:SourceFile -Encoding ascii -Force $TestAssemblyName = "TestAssembly.dll" - $TestAssemblyPath = join-path $script:TestAssemblyDir $TestAssemblyName + $TestAssemblyPath = Join-Path $script:TestAssemblyDir $TestAssemblyName Add-Type -path $script:SourceFile -OutputAssembly $TestAssemblyPath return $TestAssemblyName } - $script:TestDir = join-path $TestDrive "Remoting" + $script:TestDir = Join-Path $TestDrive "Remoting" if(-not (Test-Path $script:TestDir)) { $null = New-Item -path $script:TestDir -ItemType Directory } - $script:TestAssemblyDir = [System.IO.Path]::GetTempPath() + $script:TestAssemblyDir = Join-Path $TestDrive "AssemblyDir" if(-not (Test-Path $script:TestAssemblyDir)) { $null = New-Item -path $script:TestAssemblyDir -ItemType Directory @@ -448,14 +448,6 @@ namespace PowershellTestConfigNamespace $LocalStartupScriptPath = CreateStartupScript $LocalTestModulePath = CreateTestModule $LocalTestAssemblyName = CreateTestAssembly - $LocalTestDir = $script:TestDir - } - } - - AfterAll { - if ($IsNotSkipped) - { - Remove-Item $LocalTestDir -Recurse -Force -ErrorAction SilentlyContinue } } @@ -621,11 +613,11 @@ namespace PowershellTestConfigNamespace It "Validate New-PSSessionConfigurationFile can successfully create a valid PSSessionConfigurationFile" { - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" try { New-PSSessionConfigurationFile $configFilePath - $result = get-content $configFilePath | Out-String + $result = Get-Content $configFilePath | Out-String } finally { @@ -753,7 +745,7 @@ namespace PowershellTestConfigNamespace It "Validate FullyQualifiedErrorId from Test-PSSessionConfigurationFile when an invalid pssc file is provided as input and -Verbose parameter is specified" { - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" "InvalidData" | Out-File $configFilePath Test-PSSessionConfigurationFile $configFilePath -Verbose -ErrorAction Stop | Should -BeFalse @@ -762,7 +754,7 @@ namespace PowershellTestConfigNamespace It "Test case verifies that the generated config file passes validation" { # Path the config file - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" $updatedFunctionDefn = @() foreach($currentDefination in $parmMap.FunctionDefinitions) @@ -847,7 +839,7 @@ namespace PowershellTestConfigNamespace } It "Enable-PSSession Cmdlet creates a PSSession configuration with a name tied to PowerShell version." { - $endpointName = "PowerShell." + $PSVersionTable.GitCommitId + $endpointName = "PowerShell." + $PSVersionTable.GitCommitId.ToString() $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty } @@ -855,6 +847,10 @@ namespace PowershellTestConfigNamespace It "Enable-PSSession Cmdlet creates a default PSSession configuration untied to a specific PowerShell version." { $dotPos = $PSVersionTable.PSVersion.ToString().IndexOf(".") $endpointName = "PowerShell." + $PSVersionTable.PSVersion.ToString().Substring(0, $dotPos) + if ($PSVersionTable.GitCommitId.Contains("preview")) + { + $endpointName += "-preview" + } $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty }