windows-terminal/tools/CheckPSVersion.ps1

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

4 lines
170 B
PowerShell
Raw Permalink Normal View History

Add pre-build PowerShell version check (#14947) Two PowerShell scripts were added so that developers new to the project know if they have the wrong version of PowerShell installed. When first building Terminal, it would continuously fail, and I didn't really know why. I'm new to both this project and to open source, so when I saw an error message about "pwsh.exe" not being found I was confused and didn't know what went wrong. What I didn't know is that Windows PowerShell and PowerShell Core had different names for their .exe files, and since I had the latest version of Windows PowerShell installed, I figured that I was completely set. So, once I realized that Windows PowerShell (what I had installed) is powershell.exe and PowerShell Core (what I needed to have installed) is pwsh.exe, I downloaded PowerShell Core, and it built without issue. So, in order to help other newbies, I made two scripts, `CheckPSVersion` and `WindowsCheckPSVersion`, which make sure that PowerShell Core 7.0.0+ is installed, outputting an error telling the developer to download Core 7.0.0+ if they have Windows PowerShell but not Core. These scripts are run pre-build courtesy of `Microsoft.Terminal.Settings.ModelLib.vcxproj` ## Validation Steps Performed Building with both Windows PowerShell and PowerShell core: builds perfectly, no issues. Building with Windows PowerShell but not PowerShell core: build fails, but a nice error prints out that reminds the user to download the correct version of PowerShell core. Closes #14797
2023-04-01 07:02:29 +08:00
if($PSVersionTable.PSVersion.Major -lt 7){
Write-Error "Incorrect version of PowerShell installed.`nMake sure you have at least PowerShell Core 7.0.0."
Exit 1
}