Skip to content

Commit

Permalink
Rename powershell.exe to pwsh.exe (#5101)
Browse files Browse the repository at this point in the history
- Rename powershell.exe to pwsh.exe
- Fixe appveyor.psm1
- Update MSI to include 'pwsh' in path and app paths
- Revert change for hyper-v powershell direct
- Update names in packaging.psm1.
- Fix check for SxS
  • Loading branch information
SteveL-MSFT authored and daxian-dbw committed Oct 18, 2017
1 parent 17731cf commit 2cc0911
Show file tree
Hide file tree
Showing 51 changed files with 146 additions and 146 deletions.
1 change: 1 addition & 0 deletions .spelling
Expand Up @@ -147,6 +147,7 @@ psobjects
psproxyjobs
PSReadline
PSSessionConfiguration
pwsh
redistributables
Register-EngineEvent
Register-PSSessionConfiguration
Expand Down
16 changes: 14 additions & 2 deletions assets/Product.wxs
Expand Up @@ -31,7 +31,7 @@
<WixVariable Id="WixUIInfoIco" Value="assets\WixUIInfoIco.bmp" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open $(env.ProductName)" />
<!-- Default value of Checkbox of starting PowerShell after installation -->
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]PowerShell.exe"/>
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<UI>
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
Expand Down Expand Up @@ -73,6 +73,8 @@
<ComponentGroupRef Id="$(var.ProductVersionWithName)"/>
<ComponentRef Id="ProductVersionFolder"/>
<ComponentRef Id="ApplicationProgramsMenuShortcut"/>
<ComponentRef Id="RegistryEntries"/>
<ComponentRef Id="SetPath"/>
</Feature>
<!-- We need to show EULA, and provide option to customize download location -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
Expand Down Expand Up @@ -103,13 +105,23 @@
<Component Id="ProductVersionFolder" Guid="{e1a7f05e-0cd6-4227-80a8-e4fb311f045c}">
<CreateFolder/>
</Component>
<!-- register ourselves in application registry so can be started using just Win+R `pwsh.exe` -->
<Component Id="RegistryEntries" Guid="{402e52f7-baf8-489d-af21-f756a6ca3530}">
<RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\pwsh.exe" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
</RegistryKey>
</Component>
<!-- add ourselvs to %PATH% so pwsh.exe can be started from Windows PowerShell or cmd.exe -->
<Component Id="SetPath" Guid="{9dbb7763-7baf-48e7-b025-3bdedcb0632f}">
<Environment Id="PATH" Action="set" Name="PATH" Part="last" Permanent="no" System="yes" Value="[$(var.ProductVersionWithName)]"/>
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.ProductSemanticVersionWithName)">
<Component Id="ApplicationProgramsMenuShortcut" Guid="{A77507A7-F970-4618-AC30-20AFE36EE2EB}">
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]PowerShell.exe" WorkingDirectory="$(var.ProductVersionWithName)"
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]pwsh.exe" WorkingDirectory="$(var.ProductVersionWithName)"
Icon = "PowerShellExe.ico" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\$(var.ProductSemanticVersionWithName)\ProgramsMenuShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
Expand Down
14 changes: 7 additions & 7 deletions build.psm1
Expand Up @@ -187,7 +187,7 @@ function Start-BuildNativeWindowsBinaries {
return
}

# cmake is needed to build powershell.exe
# cmake is needed to build pwsh.exe
if (-not (precheck 'cmake' $null)) {
throw 'cmake not found. Run "Start-PSBootstrap -BuildWindowsNative". You can also install it from https://chocolatey.org/packages/cmake'
}
Expand Down Expand Up @@ -497,7 +497,7 @@ Fix steps:
Start-TypeGen
}

# Get the folder path where powershell.exe is located.
# Get the folder path where pwsh.exe is located.
$publishPath = Split-Path $Options.Output -Parent
try {
# Relative paths do not work well if cwd is not changed to project
Expand All @@ -507,7 +507,7 @@ Fix steps:

if ($CrossGen) {
Start-CrossGen -PublishPath $publishPath -Runtime $script:Options.Runtime
log "PowerShell.exe with ngen binaries is available at: $($Options.Output)"
log "pwsh.exe with ngen binaries is available at: $($Options.Output)"
} else {
log "PowerShell output: $($Options.Output)"
}
Expand Down Expand Up @@ -680,9 +680,9 @@ function New-PSOptions {
}

$Executable = if ($Environment.IsLinux -or $Environment.IsMacOS) {
"powershell"
"pwsh"
} elseif ($Environment.IsWindows) {
"powershell.exe"
"pwsh.exe"
}

# Build the Output path
Expand Down Expand Up @@ -837,7 +837,7 @@ function Start-PSPester {
[string[]]$Path = @("$PSScriptRoot/test/common","$PSScriptRoot/test/powershell"),
[switch]$ThrowOnFailure,
[string]$binDir = (Split-Path (New-PSOptions).Output),
[string]$powershell = (Join-Path $binDir 'powershell'),
[string]$powershell = (Join-Path $binDir 'pwsh'),
[string]$Pester = ([IO.Path]::Combine($binDir, "Modules", "Pester")),
[Parameter(ParameterSetName='Unelevate',Mandatory=$true)]
[switch]$Unelevate,
Expand All @@ -848,7 +848,7 @@ function Start-PSPester {
[switch]$IncludeFailingTest
)

if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue))
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue))
{
Write-Warning @"
Pester module not found.
Expand Down
2 changes: 1 addition & 1 deletion demos/Raspberry-Pi/README.md
Expand Up @@ -72,7 +72,7 @@ cp shared/Microsoft.NetCore.App/2.1.0-preview1-25719-04/* ~/powershell
## Start PowerShell

```bash
~/powershell/powershell
~/powershell/pwsh
```

Note that until arm32 is [fully supported by CoreCLR](https://github.com/dotnet/coreclr/issues/3977), it's not supported by PowerShell Core.
Expand Down
6 changes: 3 additions & 3 deletions demos/SSHRemoting/README.md
Expand Up @@ -46,9 +46,9 @@ In addition you will need to enable password authentication and optionally key b
```none
PasswordAuthentication yes
```
- Add a PowerShell subsystem entry, replace `c:/program files/powershell/6.0.0/powershell.exe` with the correct path to the version you want to use
- Add a PowerShell subsystem entry, replace `c:/program files/powershell/6.0.0/pwsh.exe` with the correct path to the version you want to use
```none
Subsystem powershell c:/program files/powershell/6.0.0/powershell.exe -sshs -NoLogo -NoProfile
Subsystem powershell c:/program files/powershell/6.0.0/pwsh.exe -sshs -NoLogo -NoProfile
```
- Optionally enable key authentication
```none
Expand Down Expand Up @@ -173,7 +173,7 @@ Microsoft Windows [Version 10.0.10586]
#
# Windows to Windows
#
C:\Users\PSUser\Documents>"C:\Program Files\PowerShell\6.0.0.17\powershell.exe"
C:\Users\PSUser\Documents>pwsh.exe
PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Expand Down
Expand Up @@ -86,7 +86,7 @@ internal sealed partial class ConsoleHost
/// </param>
/// <param name = "args">
///
/// Command line parameters to powershell.exe
/// Command line parameters to pwsh.exe
///
/// </param>
/// <returns>
Expand Down
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.PowerShell
{
/// <summary>
///
/// implementation of RawConsole for powershell.exe
/// implementation of RawConsole for powershell
///
/// </summary>

Expand Down
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.PowerShell

/// <summary>
///
/// ConsoleHostUserInterface implements console-mode user interface for powershell.exe
/// ConsoleHostUserInterface implements console-mode user interface for powershell
///
/// </summary>
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
Expand Down
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.PowerShell
{
/// <summary>
///
/// ConsoleHostUserInterface implements console-mode user interface for powershell.exe
/// ConsoleHostUserInterface implements console-mode user interface for powershell
///
/// </summary>
internal partial
Expand Down
Expand Up @@ -42,7 +42,7 @@ public sealed class ScheduledJobDefinition : ISerializable, IDisposable
private bool _isDisposed;

// Task Action strings.
private const string TaskExecutionPath = @"powershell.exe";
private const string TaskExecutionPath = @"pwsh.exe";
private const string TaskArguments = @"-NoLogo -NonInteractive -WindowStyle Hidden -Command ""Import-Module PSScheduledJob; $jobDef = [Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition]::LoadFromStore('{0}', '{1}'); $jobDef.Run()""";
private static object LockObject = new object();
private static int CurrentId = 0;
Expand Down
Expand Up @@ -503,7 +503,7 @@ public class PowerShellAssemblyLoadContextInitializer
/// </summary>
/// <remarks>
/// This method is to be used by native host whose TPA list doesn't include PS assemblies, such as the
/// in-box Nano powershell.exe, the PS remote WinRM plugin, in-box Nano DSC and in-box Nano SCOM agent.
/// in-box Nano powershell, the PS remote WinRM plugin, in-box Nano DSC and in-box Nano SCOM agent.
/// </remarks>
/// <param name="basePaths">
/// Base directory paths that are separated by semicolon ';'.
Expand Down
Expand Up @@ -39,7 +39,7 @@ protected override void ProcessRecord()
/// <summary>
/// implementation for the out-default command
/// this command it implicitly inject by the
/// powershell.exe host at the end of the pipeline as the
/// powershell host at the end of the pipeline as the
/// default sink (display to console screen)
/// </summary>
[Cmdlet(VerbsData.Out, "Default", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113362", RemotingCapability = RemotingCapability.None)]
Expand Down
Expand Up @@ -768,10 +768,15 @@ private static bool NeedToClearProcessModulePath(string currentProcessModulePath
private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath, string personalModulePath, string sharedModulePath, string psHomeModulePath)
{
#if UNIX
const string powershellExeName = "powershell";
const string powershellExeName = "pwsh";
const string oldPowershellExeName = "powershell";
#else
const string powershellExeName = "powershell.exe";
const string powershellExeName = "pwsh.exe";
const string oldPowershellExeName = "powershell.exe";
#endif
const string powershellDepsName = "pwsh.deps.json";
const string oldPowershellDepsName = "powershell.deps.json";

StringBuilder modulePathString = new StringBuilder(currentProcessModulePath.Length);
char[] invalidPathChars = Path.GetInvalidPathChars();

Expand All @@ -791,8 +796,10 @@ private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath,
{
string parentDir = Path.GetDirectoryName(trimedPath);
string psExePath = Path.Combine(parentDir, powershellExeName);
string psDepsPath = Path.Combine(parentDir, "powershell.deps.json");
if (File.Exists(psExePath) && File.Exists(psDepsPath))
string oldExePath = Path.Combine(parentDir, oldPowershellExeName);
string psDepsPath = Path.Combine(parentDir, powershellDepsName);
string oldDepsPath = Path.Combine(parentDir, oldPowershellDepsName);
if ((File.Exists(psExePath) && File.Exists(psDepsPath)) || (File.Exists(oldExePath) && File.Exists(oldDepsPath)))
{
// Path is a PSHome module path from a different powershell core instance. Ignore it.
continue;
Expand Down
Expand Up @@ -43,7 +43,7 @@ namespace System.Management.Automation.Host
public abstract class PSHost
{
/// <summary>
/// The powershell.exe spec states that 128 is the maximum nesting depth.
/// The powershell spec states that 128 is the maximum nesting depth.
/// </summary>
internal const int MaximumNestedPromptLevel = 128;
internal static bool IsStdOutputRedirected;
Expand Down
Expand Up @@ -38,10 +38,10 @@ static PowerShellProcessInstance()
{
#if UNIX
s_PSExePath = Path.Combine(Utils.DefaultPowerShellAppBase,
"powershell");
"pwsh");
#else
s_PSExePath = Path.Combine(Utils.DefaultPowerShellAppBase,
"powershell.exe");
"pwsh.exe");
#endif
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public PowerShellProcessInstance(Version powerShellVersion, PSCredential credent
#if CORECLR
string processArguments = " -s -NoLogo -NoProfile";
#else
// Adding Version parameter to powershell.exe
// Adding Version parameter to powershell
// Version parameter needs to go before all other parameters because the native layer looks for Version or
// PSConsoleFile parameters before parsing other parameters.
// The other parameters get parsed in the managed layer.
Expand Down
Expand Up @@ -2033,11 +2033,11 @@ internal override BaseClientSessionTransportManager CreateClientSessionTransport
}
#endif

// Create client ssh process that hosts powershell.exe as a subsystem and is configured
// Create client ssh process that hosts powershell as a subsystem and is configured
// to be in server mode for PSRP over SSHD:
// powershell -Version 5.1 -sshs -NoLogo -NoProfile
// powershell -sshs -NoLogo -NoProfile
// See sshd_configuration file, subsystems section and it will have this entry:
// Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 5.1 -sshs -NoLogo -NoProfile
// Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -sshs -NoLogo -NoProfile
string arguments;
if (!string.IsNullOrEmpty(this.KeyFilePath))
{
Expand Down Expand Up @@ -3164,6 +3164,8 @@ private void CreateContainerProcessInternal()
//
// Hyper-V container (i.e., RuntimeId is not empty) uses Hyper-V socket transport.
// Windows Server container (i.e., RuntimeId is empty) uses named pipe transport for now.
// This code executes `powershell.exe` as it exists in the container which currently is
// expected to be Windows PowerShell as it's inbox in the container.
//
cmd = string.Format(System.Globalization.CultureInfo.InvariantCulture,
@"{{""CommandLine"": ""powershell.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}",
Expand Down
Expand Up @@ -948,7 +948,7 @@ internal class OutOfProcessClientSessionTransportManager : OutOfProcessClientSes
#region Overrides

/// <summary>
/// Launch a new Process (PowerShell.exe -s) to perform remoting. This is used by *-Job cmdlets
/// Launch a new Process (pwsh -s) to perform remoting. This is used by *-Job cmdlets
/// to support background jobs without depending on WinRM (WinRM has complex requirements like
/// elevation to support local machine remoting)
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-native/Install-PowerShellRemoting.ps1
Expand Up @@ -116,7 +116,7 @@ if (! ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity
if ($PsCmdlet.ParameterSetName -eq "ByPath")
{
$targetPsHome = $PowerShellHome
$targetPsVersion = & "$targetPsHome\powershell" -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
$targetPsVersion = & "$targetPsHome\pwsh" -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-unix/powershell-unix.csproj
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<Description>PowerShell top-level project with .NET CLI host</Description>
<AssemblyName>powershell</AssemblyName>
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>linux-x64;osx.10.12-x64;</RuntimeIdentifiers>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/powershell-win-core/powershell-win-core.csproj
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\PowerShell.Common.props" />
<PropertyGroup>
<Description>PowerShell Core on Windows top-level project</Description>
<AssemblyName>powershell</AssemblyName>
<AssemblyName>pwsh</AssemblyName>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
<RootNamespace>Microsoft.PowerShell</RootNamespace>
Expand Down
6 changes: 3 additions & 3 deletions test/docker/networktest/DockerRemoting.Tests.ps1
Expand Up @@ -20,7 +20,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){

# get fullpath to installed core powershell
Write-Verbose -verbose "Getting path to PowerShell core"
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\powershell.exe').fullname"
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\pwsh.exe').fullname"
if ( ! $powershellcorepath )
{
$pending = $true
Expand All @@ -40,7 +40,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
# capture the versions of full and core PowerShell
write-verbose -verbose "getting powershell full version"
$fullVersion = docker exec $client powershell -c "`$psversiontable.psversion.tostring()"
if ( ! $fullVersion )
if ( ! $fullVersion )
{
$pending = $true
write-warning "Cannot determine PowerShell full version, not running tests"
Expand All @@ -49,7 +49,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){

write-verbose -verbose "getting powershell core version"
$coreVersion = docker exec $client "$powershellcorepath" -c "`$psversiontable.psversion.tostring()"
if ( ! $coreVersion )
if ( ! $coreVersion )
{
$pending = $true
write-warning "Cannot determine PowerShell core version, not running tests"
Expand Down
4 changes: 2 additions & 2 deletions test/docker/networktest/Dockerfile
@@ -1,7 +1,7 @@
# escape=`
FROM microsoft/windowsservercore

SHELL ["powershell.exe","-command"]
SHELL ["pwsh.exe","-command"]

# the source msi should change on a daily basis
# the destination should not change
Expand All @@ -18,7 +18,7 @@ RUN new-LocalUser -Name testuser -password (ConvertTo-SecureString 11aa!!AA -asp
set-item WSMan:/localhost/client/AllowUnencrypted $true; `
Start-Process -FilePath msiexec.exe -ArgumentList '-qn', `
'-i c:\PSCore.msi','-log c:\PSCore-install.log','-norestart' -wait ; `
$psexec = get-item -path ${ENV:ProgramFiles}/powershell/*/powershell.exe; `
$psexec = get-item -path ${ENV:ProgramFiles}/powershell/*/pwsh.exe; `
$corehome = $psexec.directory.fullname; `
& $psexec Install-PowerShellRemoting.ps1; `
remove-item -force c:\PSCore.msi
2 changes: 1 addition & 1 deletion test/powershell/Host/Base-Directory.Tests.ps1
@@ -1,7 +1,7 @@
Describe "Configuration file locations" -tags "CI","Slow" {

BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "powershell"
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$profileName = "Microsoft.PowerShell_profile.ps1"
}

Expand Down

0 comments on commit 2cc0911

Please sign in to comment.