Skip to content

Commit 29e2147

Browse files
SteveL-MSFTdaxian-dbw
authored andcommitted
Port PowerShell to .NET Core 3.0 (PowerShell#9597)
1 parent afa76de commit 29e2147

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+695
-631
lines changed

PowerShell.Common.props

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
Tracking Issue https://github.com/dotnet/sdk/issues/1557
6363
-->
6464
<PackageVersion>$(PSCoreBuildVersion)</PackageVersion>
65+
<ApplicationIcon Condition="$(ProductVersion.Contains('preview'))">..\..\assets\Powershell_av_colors.ico</ApplicationIcon>
66+
<ApplicationIcon Condition="!$(ProductVersion.Contains('preview'))">..\..\assets\Powershell_black.ico</ApplicationIcon>
6567

6668
</PropertyGroup>
6769

@@ -93,9 +95,8 @@
9395
<Company>Microsoft Corporation</Company>
9496
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
9597

96-
<TargetFramework>netcoreapp2.1</TargetFramework>
97-
<RuntimeFrameworkVersion>2.1.8</RuntimeFrameworkVersion>
98-
<LangVersion>Latest</LangVersion>
98+
<TargetFramework>netcoreapp3.0</TargetFramework>
99+
<LangVersion>8.0</LangVersion>
99100

100101
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
101102
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

assets/files.wxs

+481-435
Large diffs are not rendered by default.

build.psm1

+8-64
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# On Windows paths is separated by semicolon
66
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator
77

8-
$dotnetCLIChannel = "release"
8+
$dotnetCLIChannel = 'preview' # TODO: Change this to 'release' once .Net Core 3.0 goes RTM
99
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
1010

1111
# Track if tags have been sync'ed
@@ -410,7 +410,7 @@ Fix steps:
410410
Pop-Location
411411
}
412412

413-
# publish netcoreapp2.1 reference assemblies
413+
# publish reference assemblies
414414
try {
415415
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
416416
$refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
@@ -449,51 +449,6 @@ Fix steps:
449449
}
450450
}
451451

452-
if ($Environment.IsWindows) {
453-
## need RCEdit to modify the binaries embedded resources
454-
$rcedit = "~/.rcedit/rcedit-x64.exe"
455-
if (-not (Test-Path -Type Leaf $rcedit)) {
456-
$rcedit = Get-Command "rcedit-x64.exe" -CommandType Application -ErrorAction Ignore | Select-Object -First 1 | ForEach-Object Name
457-
}
458-
if (-not $rcedit) {
459-
throw "RCEdit is required to modify pwsh.exe resources, please run 'Start-PSBootStrap' to install"
460-
}
461-
462-
$ReleaseVersion = ""
463-
if ($ReleaseTagToUse) {
464-
$ReleaseVersion = $ReleaseTagToUse
465-
} else {
466-
$ReleaseVersion = (Get-PSCommitId -WarningAction SilentlyContinue) -replace '^v'
467-
}
468-
# in VSCode, depending on where you started it from, the git commit id may be empty so provide a default value
469-
if (!$ReleaseVersion) {
470-
$ReleaseVersion = "6.0.0"
471-
$fileVersion = "6.0.0"
472-
} else {
473-
$fileVersion = $ReleaseVersion.Split("-")[0]
474-
}
475-
476-
# in VSCode, the build output folder doesn't include the name of the exe so we have to add it for rcedit
477-
$pwshPath = $Options.Output
478-
if (!$pwshPath.EndsWith("pwsh.exe")) {
479-
$pwshPath = Join-Path $Options.Output "pwsh.exe"
480-
}
481-
482-
if (Test-IsPreview $ReleaseVersion) {
483-
$iconPath = "$PSScriptRoot\assets\Powershell_av_colors.ico"
484-
} else {
485-
$iconPath = "$PSScriptRoot\assets\Powershell_black.ico"
486-
}
487-
488-
# fxdependent package does not have an executable to set iconPath etc.
489-
if ($Options.Runtime -ne 'fxdependent') {
490-
Start-NativeExecution { & $rcedit $pwshPath --set-icon $iconPath `
491-
--set-file-version $fileVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell 7" `
492-
--set-version-string "LegalCopyright" "(C) Microsoft Corporation. All Rights Reserved." `
493-
--application-manifest "$PSScriptRoot\assets\pwsh.manifest" } | Write-Verbose
494-
}
495-
}
496-
497452
# download modules from powershell gallery.
498453
# - PowerShellGet, PackageManagement, Microsoft.PowerShell.Archive
499454
if ($PSModuleRestore) {
@@ -617,8 +572,8 @@ function New-PSOptions {
617572
[ValidateSet("Debug", "Release", "CodeCoverage", '')]
618573
[string]$Configuration,
619574

620-
[ValidateSet("netcoreapp2.1")]
621-
[string]$Framework,
575+
[ValidateSet("netcoreapp3.0")]
576+
[string]$Framework = "netcoreapp3.0",
622577

623578
# These are duplicated from Start-PSBuild
624579
# We do not use ValidateScript since we want tab completion
@@ -656,6 +611,7 @@ function New-PSOptions {
656611
}
657612

658613
Write-Verbose "Using configuration '$Configuration'"
614+
Write-Verbose "Using framework '$Framework'"
659615

660616
if (-not $Runtime) {
661617
if ($Environment.IsLinux) {
@@ -1741,19 +1697,6 @@ function Start-PSBootstrap {
17411697
$psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1")
17421698
& $psInstallFile -AddToPath
17431699
}
1744-
1745-
## need RCEdit to modify the binaries embedded resources
1746-
if (-not (Test-Path "~/.rcedit/rcedit-x64.exe"))
1747-
{
1748-
Write-Log "Install RCEdit for modifying exe resources"
1749-
$rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.0.0/rcedit-x64.exe"
1750-
New-Item -Path "~/.rcedit" -Type Directory -Force > $null
1751-
1752-
## need to specify TLS version 1.2 since GitHub API requires it
1753-
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
1754-
1755-
Invoke-WebRequest -OutFile "~/.rcedit/rcedit-x64.exe" -Uri $rceditUrl
1756-
}
17571700
}
17581701
} finally {
17591702
Pop-Location
@@ -1854,12 +1797,13 @@ function Start-TypeGen
18541797
<Target Name="_GetDependencies"
18551798
DependsOnTargets="ResolveAssemblyReferencesDesignTime">
18561799
<ItemGroup>
1857-
<_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
1800+
<_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
18581801
</ItemGroup>
18591802
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
18601803
</Target>
18611804
</Project>
18621805
'@
1806+
New-Item -ItemType Directory -Path (Split-Path -Path $GetDependenciesTargetPath -Parent) -Force > $null
18631807
Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii
18641808

18651809
Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
@@ -2317,7 +2261,7 @@ function Copy-PSGalleryModules
23172261
Remove-Item -Force -ErrorAction Ignore -Recurse "$Destination/$name"
23182262
New-Item -Path $dest -ItemType Directory -Force -ErrorAction Stop > $null
23192263
# Exclude files/folders that are not needed. The fullclr folder is coming from the PackageManagement module
2320-
$dontCopy = '*.nupkg', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll', 'fullclr'
2264+
$dontCopy = '*.nupkg', '*.nupkg.metadata', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll', 'fullclr'
23212265
Copy-Item -Exclude $dontCopy -Recurse $src/* $dest
23222266
}
23232267
}

docs/building/linux.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Start-PSBuild
7171
Congratulations! If everything went right, PowerShell is now built.
7272
The `Start-PSBuild` script will output the location of the executable:
7373

74-
`./src/powershell-unix/bin/Debug/netcoreapp2.1/linux-x64/publish/pwsh`.
74+
`./src/powershell-unix/bin/Debug/netcoreapp3.0/linux-x64/publish/pwsh`.
7575

7676
You should now be running the PowerShell Core that you just built, if your run the above executable.
7777
You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`.

docs/building/macos.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ We cannot do this for you in the build module due to #[847][].
3636

3737
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module.
3838

39-
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp2.1/osx-x64/publish/pwsh`.
39+
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/netcoreapp3.0/osx-x64/publish/pwsh`.

docs/building/windows-core.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Import-Module ./build.psm1
5858
Start-PSBuild
5959
```
6060

61-
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp2.1/win7-x64/publish/pwsh.exe`.
61+
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/netcoreapp3.0/win7-x64/publish/pwsh.exe`.
6262

6363
This location is of the form `./[project]/bin/[configuration]/[framework]/[rid]/publish/[binary name]`,
6464
and our project is `powershell`, configuration is `Debug` by default,
65-
framework is `netcoreapp2.1`, runtime identifier is `win7-x64` by default,
65+
framework is `netcoreapp3.0`, runtime identifier is `win7-x64` by default,
6666
and binary name is `pwsh`.
6767
The function `Get-PSOutput` will return the path to the executable;
6868
thus you can execute the development copy via `& (Get-PSOutput)`.

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.504"
3+
"version": "3.0.100-preview5-011568"
44
}
55
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ private void LoadAssemblies(IEnumerable<string> assemblies)
663663
/// </summary>
664664
private static IEnumerable<PortableExecutableReference> InitDefaultRefAssemblies()
665665
{
666-
// netcoreapp2.1 currently comes with 144 reference assemblies (maybe more in future), so we use a capacity of '150'.
666+
// netcoreapp3.0 currently comes with 148 reference assemblies (maybe more in future), so we use a capacity of '150'.
667667
var defaultRefAssemblies = new List<PortableExecutableReference>(150);
668668

669669
foreach (string file in Directory.EnumerateFiles(s_netcoreAppRefFolder, "*.dll", SearchOption.TopDirectoryOnly))

src/ResGen/ResGen.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<PropertyGroup>
44
<Description>Generates C# typed bindings for .resx files</Description>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
<AssemblyName>resgen</AssemblyName>
77
<OutputType>Exe</OutputType>
88
<TieredCompilation>true</TieredCompilation>
9+
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
910
<RuntimeIdentifiers>win7-x86;win7-x64;osx-x64;linux-x64</RuntimeIdentifiers>
1011
</PropertyGroup>
1112

src/System.Management.Automation/engine/PSVersionInfo.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public class PSVersionInfo
6060
private static Version s_psV4Version = new Version(4, 0);
6161
private static Version s_psV5Version = new Version(5, 0);
6262
private static Version s_psV51Version = new Version(5, 1, NTVerpVars.PRODUCTBUILD, NTVerpVars.PRODUCTBUILD_QFE);
63-
private static SemanticVersion s_psV6Version;
63+
private static SemanticVersion s_psV6Version = new SemanticVersion(6, 0, 0, null, null);
64+
private static SemanticVersion s_psV7Version;
6465

6566
/// <summary>
6667
/// A constant to track current PowerShell Edition.
@@ -99,12 +100,12 @@ static PSVersionInfo()
99100
rawGitCommitId = mainVersion;
100101
}
101102

102-
s_psV6Version = new SemanticVersion(mainVersion);
103+
s_psV7Version = new SemanticVersion(mainVersion);
103104

104-
s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version;
105+
s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV7Version;
105106
s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue;
106107
s_psVersionTable[PSGitCommitIdName] = rawGitCommitId;
107-
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version };
108+
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV7Version };
108109
s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion);
109110
s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
110111
s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion();
@@ -271,6 +272,11 @@ internal static string FeatureVersionString
271272

272273
internal static bool IsValidPSVersion(Version version)
273274
{
275+
if (version.Major == s_psV7Version.Major)
276+
{
277+
return version.Minor == s_psV7Version.Minor;
278+
}
279+
274280
if (version.Major == s_psV6Version.Major)
275281
{
276282
return version.Minor == s_psV6Version.Minor;
@@ -321,6 +327,11 @@ internal static SemanticVersion PSV6Version
321327
get { return s_psV6Version; }
322328
}
323329

330+
internal static SemanticVersion PSV7Version
331+
{
332+
get { return s_psV7Version; }
333+
}
334+
324335
#endregion
325336
}
326337

src/System.Management.Automation/engine/Utils.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1182,8 +1182,6 @@ internal static bool IsReservedDeviceName(string destinationPath)
11821182
string compareName = Path.GetFileName(destinationPath);
11831183
string noExtensionCompareName = Path.GetFileNameWithoutExtension(destinationPath);
11841184

1185-
// See if it's the correct length. If it's shorter than CON, AUX, etc, it can't be a device name.
1186-
// Likewise, if it's longer than 'CLOCK$', it can't be a device name.
11871185
if (((compareName.Length < 3) || (compareName.Length > 6)) &&
11881186
((noExtensionCompareName.Length < 3) || (noExtensionCompareName.Length > 6)))
11891187
{

src/System.Management.Automation/namespaces/NavigationProviderBase.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected string MakePath(string parent, string child, bool childIsLeaf)
335335
// If the parent is empty but the child is not, return the
336336
// child
337337

338-
result = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
338+
result = NormalizePath(child);
339339
}
340340
else if (!string.IsNullOrEmpty(parent) &&
341341
string.IsNullOrEmpty(child))
@@ -369,8 +369,8 @@ protected string MakePath(string parent, string child, bool childIsLeaf)
369369
// Normalize the path so that only the default path separator is used as a
370370
// separator even if the user types the alternate slash.
371371

372-
parent = parent.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
373-
child = child.Replace(StringLiterals.AlternatePathSeparator, StringLiterals.DefaultPathSeparator);
372+
parent = NormalizePath(parent);
373+
child = NormalizePath(child);
374374
}
375375

376376
// Joins the paths

src/TypeCatalogGen/TypeCatalogGen.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<PropertyGroup>
44
<Description>Generates CorePsTypeCatalog.cs given powershell.inc</Description>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
<AssemblyName>TypeCatalogGen</AssemblyName>
77
<OutputType>Exe</OutputType>
88
<TieredCompilation>true</TieredCompilation>
9+
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
910
<RuntimeIdentifiers>win7-x86;win7-x64;osx-x64;linux-x64</RuntimeIdentifiers>
1011
</PropertyGroup>
1112

src/powershell-native/Install-PowerShellRemoting.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Register-WinRmPlugin
6767
SDKVersion="2" XmlRenderingType="text" Enabled="True" OutputBufferingMode="Block" ProcessIdleTimeoutSec="0" Architecture="{2}"
6868
UseSharedProcess="false" RunAsUser="" RunAsPassword="" AutoRestart="false">
6969
<InitializationParameters>
70-
<Param Name="PSVersion" Value="6.0"/>
70+
<Param Name="PSVersion" Value="7.0"/>
7171
</InitializationParameters>
7272
<Resources>
7373
<Resource ResourceUri="http://schemas.microsoft.com/powershell/{0}" SupportsOptions="true" ExactMatch="true">

src/powershell-unix/powershell-unix.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<AssemblyName>pwsh</AssemblyName>
88
<OutputType>Exe</OutputType>
99
<TieredCompilation>true</TieredCompilation>
10+
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
1011
<RuntimeIdentifiers>linux-x64;osx-x64;</RuntimeIdentifiers>
1112
</PropertyGroup>
1213

src/powershell-win-core/powershell-win-core.csproj

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
1+
<Project ToolsVersion="15.0">
22
<Import Project="..\..\PowerShell.Common.props" />
3+
34
<PropertyGroup>
45
<Description>PowerShell on Windows top-level project</Description>
56
<AssemblyName>pwsh</AssemblyName>
67
<OutputType>Exe</OutputType>
78
<TieredCompilation>true</TieredCompilation>
9+
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
810
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
911
<RootNamespace>Microsoft.PowerShell</RootNamespace>
12+
<ApplicationManifest>..\..\assets\pwsh.manifest</ApplicationManifest>
1013
</PropertyGroup>
1114

15+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition="'$(RuntimeIdentifier)' == 'win-arm' or '$(RuntimeIdentifier)' == 'win-arm64'" />
16+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition="'$(RuntimeIdentifier)' == 'win-arm' or '$(RuntimeIdentifier)' == 'win-arm64'" />
17+
18+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(RuntimeIdentifier)' != 'win-arm' and '$(RuntimeIdentifier)' != 'win-arm64'" />
19+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(RuntimeIdentifier)' != 'win-arm' and '$(RuntimeIdentifier)' != 'win-arm64'" />
20+
1221
<ItemGroup>
1322
<Compile Include="..\powershell\Program.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
1423
<Content Include="..\System.Management.Automation\powershell.config.json">

test/Test.Common.props

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
<Company>Microsoft Corporation</Company>
55
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
66

7-
<TargetFramework>netcoreapp2.1</TargetFramework>
8-
<RuntimeFrameworkVersion>2.1.8</RuntimeFrameworkVersion>
9-
<LangVersion>Latest</LangVersion>
7+
<TargetFramework>netcoreapp3.0</TargetFramework>
8+
<LangVersion>8.0</LangVersion>
109

1110
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1211
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

test/hosting/hosting.tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageReference Include="xunit" Version="2.4.0" />
1919
<PackageReference Include="XunitXml.TestLogger" Version="2.0.0" />
2020
<!-- The version of Microsoft.PowerShell.SDK should be the version we are releasing, so the tests use the correct SDK before publishing to NuGet.org -->
21-
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.0-rc.1" />
21+
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.0" />
2222
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
2323
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
2424
</ItemGroup>

test/powershell/Host/ConsoleHost.Tests.ps1

+8-3
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,14 @@ Describe "Console host api tests" -Tag CI {
824824
Describe "Pwsh exe resources tests" -Tag CI {
825825
It "Resource strings are embedded in the executable" -Skip:(!$IsWindows) {
826826
$pwsh = Get-Item -Path "$PSHOME\pwsh.exe"
827-
$pwsh.VersionInfo.FileVersion | Should -BeExactly $PSVersionTable.PSVersion.ToString().Split("-")[0]
828-
$pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId
829-
$pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell 7"
827+
$pwsh.VersionInfo.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0]
828+
$productVersion = $pwsh.VersionInfo.ProductVersion.Replace("-dirty","").Replace(" Commits: ","-").Replace(" SHA: ","-g")
829+
if ($PSVersionTable.GitCommitId.Contains("-g")) {
830+
$productVersion | Should -BeExactly $PSVersionTable.GitCommitId
831+
} else {
832+
$productVersion | Should -Match $PSVersionTable.GitCommitId
833+
}
834+
$pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell"
830835
}
831836

832837
It "Manifest contains compatibility section" -Skip:(!$IsWindows) {

test/powershell/Host/PSVersionTable.Tests.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Describe "PSVersionTable" -Tags "CI" {
4545
$PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion"
4646
$PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion
4747
$PSVersionTable.PSVersion | Should -Match $expectedVersionPattern
48-
$PSVersionTable.PSVersion.Major | Should -Be 6
48+
$PSVersionTable.PSVersion.Major | Should -Be 7
4949
}
5050

5151
It "GitCommitId property" {

0 commit comments

Comments
 (0)