Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/PSVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the removal of this TODO mean we no longer intend for this to happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of this comment means that the current design supports semver (pre-release labels)

// closer to release. Right now it doesn't support alpha versions.
return System.String.Concat("PowerShell.", PSVersionInfo.GitCommitId);
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
8 changes: 4 additions & 4 deletions test/powershell/Host/PSVersionTable.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -847,14 +839,18 @@ 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
}

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
}
Expand Down