-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Rename powershell.exe to pwsh.exe #5101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b516aed
to
7dd72f9
Compare
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full path is removed here. Is this because we are putting it to %PATH%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the msi installer to add it to %PATH%, I wanted to remove it since it references a specific version path. I'll do the msi update separate from this PR.
@@ -418,7 +418,7 @@ Describe "TabCompletion" -Tags CI { | |||
@{ inputStr = 'gmo -list PackageM'; expected = 'PackageManagement'; setup = $null } | |||
@{ inputStr = 'gcm -Module PackageManagement Find-Pac'; expected = 'Find-Package'; setup = $null } | |||
@{ inputStr = 'ipmo PackageM'; expected = 'PackageManagement'; setup = $null } | |||
@{ inputStr = 'Get-Process powersh'; expected = 'powershell'; setup = $null } | |||
@{ inputStr = 'Get-Process pws'; expected = 'pwsh'; setup = $null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo -- pws
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the tab completion test so pws
completes to pwsh
since there isn't necessarily a powershell
process anymore and pw
might resolve to something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, my mistake.
rebased to fix merge conflict |
@@ -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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code assumes a discoverable pwsh.exe native command. Does this fix include adding pwsh.exe to the system path environment variable? If so what version? I wonder if we should allow the user to select a powershell.exe or pwsh.exe path to use for scheduled jobs (maybe in a separate issue/pr).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use Utils.DefaultPowerShellAppBase here as we do with PowerShellProcessInstance.cs to ensure the scheduled job is using the correct path.
The problem with scheduled jobs is that they can run indefinitely on a machine and if pwsh.exe is uninstalled or installed to a new location then they will break. Of course we have a similar problem with credentials expiring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a separate PR coming for the msi installer to append to %PATH% which would also solve the Win+R->pwsh usage
If PSCore6 is uninstalled, the full path won't help either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'll do the %PATH% msi change as part of this PR as it's more useful that pwsh.exe differs form powershell.exe and I can put it at the end of the path rather than taking over the front
@@ -3166,7 +3166,7 @@ private void CreateContainerProcessInternal() | |||
// Windows Server container (i.e., RuntimeId is empty) uses named pipe transport for now. | |||
// | |||
cmd = string.Format(System.Globalization.CultureInfo.InvariantCulture, | |||
@"{{""CommandLine"": ""powershell.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}", | |||
@"{{""CommandLine"": ""pwsh.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here in that we rely on a "built-in" pwsh.exe command that is discoverable. But we have the same issue with ssh.exe used for SSH based remoting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually as I think about it, we don't want to change this here. This is a command run on a target VM and relies on the built-in Windows PowerShell. pwsh.exe will not be available on a new VM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this command is run within the VM expecting Windows PowerShell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will change back.
04257cd
to
d426d98
Compare
b4daecd
to
da7e7fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@daxian-dbw can you review again since last commit? |
@@ -791,8 +793,9 @@ private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath, | |||
{ | |||
string parentDir = Path.GetDirectoryName(trimedPath); | |||
string psExePath = Path.Combine(parentDir, powershellExeName); | |||
string oldExePath = Path.Combine(parentDir, oldPowershellExeName); | |||
string psDepsPath = Path.Combine(parentDir, "powershell.deps.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you change it to pwsh
in csproj, I guess the .deps.json file will be changed to pwsh.deps.json
.
But maybe you want to keep the check for powershell.deps.json
for now just like the check for old "powershell.exe".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it did get changed to pwsh.deps.json
, will add oldDepsPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daxian-dbw Do we really even need the deps.json check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep it for now
assets/Product.wxs
Outdated
</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="yes" System="yes" Value="[$(var.ProductVersionWithName)]"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we remove the path when uninstalling the package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
#else | ||
const string powershellExeName = "pwsh.exe"; | ||
const string oldPowershellExeName = "powershell.exe"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove the old exe name when we reach RC/RTM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still needed if we start pwsh from Windows PowerShell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "start pwsh from windows powershell" case is handled in NeedToClearProcessModulePath
, and RemoveSxSPsHomeModulePath
only handles powershell core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the .deps.json file check, this doesn't apply to Windows PowerShell anyways. We can remove at RC/GA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I will open an issue on this -- #5135
@@ -3166,7 +3166,7 @@ private void CreateContainerProcessInternal() | |||
// Windows Server container (i.e., RuntimeId is empty) uses named pipe transport for now. | |||
// | |||
cmd = string.Format(System.Globalization.CultureInfo.InvariantCulture, | |||
@"{{""CommandLine"": ""pwsh.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}", | |||
@"{{""CommandLine"": ""powershell.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining why powershell.exe
is used here will be helpful when looking at this code in future.
@SteveL-MSFT One more issue: when creating Unix packages, symbolic link is created to point to Besides, are you planning to change the package name? (I assume not). https://github.com/PowerShell/PowerShell/blob/master/tools/packaging/packaging.psm1#L459 |
@daxian-dbw will update the symlink, the package name is not changing |
fc91109
to
b4a10fa
Compare
@@ -1,7 +1,7 @@ | |||
# escape=` | |||
FROM microsoft/windowsservercore | |||
|
|||
SHELL ["powershell.exe","-command"] | |||
SHELL ["pwsh.exe","-command"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't break docker... there are tests in docker/tests
. All tests can be can be run from windows, just run them once with the docker daemon set to windows mode and once set to Linux mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is before PSCore has been installed. So this won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just notice this is a test file, not a production docker file.
missed test generating fake .deps.json file no longer need code in packaging.psm1 to ensure binaries are named correctly (since dotnet does it correctly now) updated symlinks in packaging, didn't update $name value since it appears to be used for the package name which isn't changing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some more updates to the packaging.psm1 regarding the name change.
I think we also need to update the docker files, including those in docker/release
and tools\releaseBuild\Images
. But I'm OK if you want to do that in a separate PR.
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(oldDepsPath) && File.Exists(oldDepsPath))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(File.Exists(oldDepsPath) && File.Exists(oldDepsPath))
One of them should be oldExePath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
Let's do the docker updates as separate PR |
Shouldn't this be an alias vs a complete rename? Please point me to the discussion where the decision to rename took place. Thanks |
@tmknight here is where the PowerShell comitee's decision was announced: #4214 (comment) |
renamed powershell.exe to pwsh.exe
updated powershell core code dependencies, console host references, and tests
updated vscode json files
updated docker files
updated logic in moduleintrinsics.cs to account for SxS where you are starting pwsh from powershell.exe
Fix #4214