Skip to content

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

Merged
merged 7 commits into from
Oct 18, 2017
Merged

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Oct 12, 2017

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

@@ -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
Copy link
Member

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%?

Copy link
Member Author

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 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typo -- pws

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, my mistake.

renamed powershell.exe to pwsh.exe
@SteveL-MSFT
Copy link
Member Author

rebased to fix merge conflict

fixed check in appveyor.psm1
@@ -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";
Copy link
Contributor

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).

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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}}}",
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will change back.

@SteveL-MSFT SteveL-MSFT force-pushed the pwsh branch 2 times, most recently from 04257cd to d426d98 Compare October 14, 2017 01:36
updated msi to include pwsh in path and app paths
reverted change for hyper-v powershell direct
reapplied test changes reverted by rebase
@SteveL-MSFT SteveL-MSFT force-pushed the pwsh branch 2 times, most recently from b4daecd to da7e7fe Compare October 14, 2017 02:23
Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SteveL-MSFT
Copy link
Member Author

@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");
Copy link
Member

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".

Copy link
Member Author

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

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Oct 16, 2017

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we didn't have the .deps.json check initially and it caused a build break and the fix was to add this deps.json check. Here is the related issue #1744 and #1792

Not sure if that requirement is applicable now.

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Oct 16, 2017

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

</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)]"/>
Copy link
Member

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?

Copy link
Member Author

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";
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

@daxian-dbw daxian-dbw Oct 16, 2017

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}}}",
Copy link
Member

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.

@daxian-dbw
Copy link
Member

@SteveL-MSFT One more issue: when creating Unix packages, symbolic link is created to point to powershell in $pshome (see the following places). You need to update the symbolic link file name and the target file name.

Besides, are you planning to change the package name? (I assume not).

https://github.com/PowerShell/PowerShell/blob/master/tools/packaging/packaging.psm1#L459
https://github.com/PowerShell/PowerShell/blob/master/tools/packaging/packaging.psm1#L471
https://github.com/PowerShell/PowerShell/blob/master/tools/packaging/packaging.psm1#L587

@SteveL-MSFT
Copy link
Member Author

@daxian-dbw will update the symlink, the package name is not changing

address PR feedback
@SteveL-MSFT SteveL-MSFT force-pushed the pwsh branch 2 times, most recently from fc91109 to b4a10fa Compare October 16, 2017 22:30
@@ -1,7 +1,7 @@
# escape=`
FROM microsoft/windowsservercore

SHELL ["powershell.exe","-command"]
SHELL ["pwsh.exe","-command"]
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

@daxian-dbw daxian-dbw left a 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)))
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix

@SteveL-MSFT
Copy link
Member Author

Let's do the docker updates as separate PR

fix check for SxS
@tmknight
Copy link

Shouldn't this be an alias vs a complete rename? Please point me to the discussion where the decision to rename took place. Thanks

@markekraus
Copy link
Contributor

@tmknight here is where the PowerShell comitee's decision was announced: #4214 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking-Change breaking change that may affect users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants