mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Update Enable-PSRemoting so configuration name for Preview releases (#7202)
The intent was to have the version of the PSSessionConfiguration name not include the `v` for the version string. Also, Preview releases should standardize on `PowerShell.6-Preview` instead of clobbering `PowerShell.6` so that stable and preview can co-exist side-by-side. Need to verify on Win10 IoT if `Install-PowerShellRemoting.ps1` is still needed anymore as it may be possible to run `pwsh -c enable-psremoting` from within Windows PowerShell Core removing the need for that script which duplicates `Enable-PSRemoting` capability. Update: Not able to get the current master build working on Win10 IoT, getting `Invalid access to memory` error. Will have to investigate this separately from this PR and keep `Install-PowerShellRemoting.ps1` for now. Fix https://github.com/PowerShell/PowerShell/issues/7119
This commit is contained in:
@@ -78,11 +78,11 @@ namespace System.Management.Automation
|
||||
|
||||
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);
|
||||
|
||||
@@ -1517,8 +1517,6 @@ else
|
||||
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 @@ else
|
||||
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 @@ param(
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+18
-22
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user