Skip to content

Commit b4daecd

Browse files
committed
[feature]
updated msi to include pwsh in path and app paths reverted change for hyper-v powershell direct reapplied test changes reverted by rebase
1 parent d992c7b commit b4daecd

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

assets/Product.wxs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<WixVariable Id="WixUIInfoIco" Value="assets\WixUIInfoIco.bmp" />
3232
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open $(env.ProductName)" />
3333
<!-- Default value of Checkbox of starting PowerShell after installation -->
34-
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]PowerShell.exe"/>
34+
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
3535
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
3636
<UI>
3737
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
@@ -73,6 +73,8 @@
7373
<ComponentGroupRef Id="$(var.ProductVersionWithName)"/>
7474
<ComponentRef Id="ProductVersionFolder"/>
7575
<ComponentRef Id="ApplicationProgramsMenuShortcut"/>
76+
<ComponentRef Id="RegistryEntries"/>
77+
<ComponentRef Id="SetPath"/>
7678
</Feature>
7779
<!-- We need to show EULA, and provide option to customize download location -->
7880
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
@@ -103,13 +105,23 @@
103105
<Component Id="ProductVersionFolder" Guid="{e1a7f05e-0cd6-4227-80a8-e4fb311f045c}">
104106
<CreateFolder/>
105107
</Component>
108+
<!-- register ourselves in application registry so can be started using just Win+R `pwsh.exe` -->
109+
<Component Id="RegistryEntries" Guid="{402e52f7-baf8-489d-af21-f756a6ca3530}">
110+
<RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\pwsh.exe" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
111+
<RegistryValue Type="string" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
112+
</RegistryKey>
113+
</Component>
114+
<!-- add ourselvs to %PATH% so pwsh.exe can be started from Windows PowerShell or cmd.exe -->
115+
<Component Id="SetPath" Guid="{9dbb7763-7baf-48e7-b025-3bdedcb0632f}">
116+
<Environment Id="PATH" Action="set" Name="PATH" Part="last" Permanent="yes" System="yes" Value="[$(var.ProductVersionWithName)]"/>
117+
</Component>
106118
</Directory>
107119
</Directory>
108120
</Directory>
109121
<Directory Id="ProgramMenuFolder">
110122
<Directory Id="ApplicationProgramsFolder" Name="$(var.ProductSemanticVersionWithName)">
111123
<Component Id="ApplicationProgramsMenuShortcut" Guid="{A77507A7-F970-4618-AC30-20AFE36EE2EB}">
112-
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]PowerShell.exe" WorkingDirectory="$(var.ProductVersionWithName)"
124+
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithName)" Description="$(var.ProductSemanticVersionWithName)" Target="[$(var.ProductVersionWithName)]pwsh.exe" WorkingDirectory="$(var.ProductVersionWithName)"
113125
Icon = "PowerShellExe.ico" />
114126
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
115127
<RegistryValue Root="HKCU" Key="Software\Microsoft\$(var.ProductSemanticVersionWithName)\ProgramsMenuShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>

src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath,
769769
{
770770
#if UNIX
771771
const string powershellExeName = "pwsh";
772+
const string oldPowershellExeName = "powershell";
772773
#else
773774
const string powershellExeName = "pwsh.exe";
775+
const string oldPowershellExeName = "powershell.exe";
774776
#endif
775777
StringBuilder modulePathString = new StringBuilder(currentProcessModulePath.Length);
776778
char[] invalidPathChars = Path.GetInvalidPathChars();
@@ -791,8 +793,9 @@ private static string RemoveSxSPsHomeModulePath(string currentProcessModulePath,
791793
{
792794
string parentDir = Path.GetDirectoryName(trimedPath);
793795
string psExePath = Path.Combine(parentDir, powershellExeName);
796+
string oldExePath = Path.Combine(parentDir, oldPowershellExeName);
794797
string psDepsPath = Path.Combine(parentDir, "powershell.deps.json");
795-
if (File.Exists(psExePath) && File.Exists(psDepsPath))
798+
if ((File.Exists(psExePath) || File.Exists(oldExePath)) && File.Exists(psDepsPath))
796799
{
797800
// Path is a PSHome module path from a different powershell core instance. Ignore it.
798801
continue;

src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,7 @@ private void CreateContainerProcessInternal()
31663166
// Windows Server container (i.e., RuntimeId is empty) uses named pipe transport for now.
31673167
//
31683168
cmd = string.Format(System.Globalization.CultureInfo.InvariantCulture,
3169-
@"{{""CommandLine"": ""pwsh.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}",
3169+
@"{{""CommandLine"": ""powershell.exe {0} -NoLogo {1}"",""RestrictedToken"": {2}}}",
31703170
(RuntimeId != Guid.Empty) ? "-so -NoProfile" : "-NamedPipeServerMode",
31713171
String.IsNullOrEmpty(ConfigurationName) ? String.Empty : String.Concat("-Config ", ConfigurationName),
31723172
(RunAsAdmin) ? "false" : "true");

test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Describe "TabCompletion" -Tags CI {
355355
@{ inputStr = '$host.UI.WriteD'; expected = 'WriteDebugLine('; setup = $null }
356356
@{ inputStr = '$MaximumHistoryCount.'; expected = 'CompareTo('; setup = $null }
357357
@{ inputStr = '$A=[datetime]::now;$A.'; expected = 'Date'; setup = $null }
358-
@{ inputStr = '$x= gps powershell;$x.*pm'; expected = 'NPM'; setup = $null }
358+
@{ inputStr = '$x= gps pwsh;$x.*pm'; expected = 'NPM'; setup = $null }
359359
@{ inputStr = 'function write-output {param($abcd) $abcd};Write-Output -a'; expected = '-abcd'; setup = $null }
360360
@{ inputStr = 'function write-output {param($abcd) $abcd};Microsoft.PowerShell.Utility\Write-Output -'; expected = '-InputObject'; setup = $null }
361361
@{ inputStr = '[math]::Co'; expected = 'Cos('; setup = $null }
@@ -418,7 +418,7 @@ Describe "TabCompletion" -Tags CI {
418418
@{ inputStr = 'gmo -list PackageM'; expected = 'PackageManagement'; setup = $null }
419419
@{ inputStr = 'gcm -Module PackageManagement Find-Pac'; expected = 'Find-Package'; setup = $null }
420420
@{ inputStr = 'ipmo PackageM'; expected = 'PackageManagement'; setup = $null }
421-
@{ inputStr = 'Get-Process powersh'; expected = 'powershell'; setup = $null }
421+
@{ inputStr = 'Get-Process pws'; expected = 'pwsh'; setup = $null }
422422
@{ inputStr = "function bar { [OutputType('System.IO.FileInfo')][OutputType('System.Diagnostics.Process')]param() }; bar | ? { `$_.ProcessN"; expected = 'ProcessName'; setup = $null }
423423
@{ inputStr = "function bar { [OutputType('System.IO.FileInfo')][OutputType('System.Diagnostics.Process')]param() }; bar | ? { `$_.LastAc"; expected = 'LastAccessTime'; setup = $null }
424424
@{ inputStr = "& 'get-comm"; expected = "'Get-Command'"; setup = $null }

test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
Context "Export-CliXml" {
3939
BeforeAll {
40-
$gpsList = Get-Process powershell
40+
$gpsList = Get-Process pwsh
4141
$gps = $gpsList | Select-Object -First 1
4242
$filePath = Join-Path $subFilePath 'gps.xml'
4343

@@ -213,7 +213,7 @@ Describe "Deserializing corrupted Cim classes should not instantiate non-Cim typ
213213
It "Verifies that importing the corrupted Cim class does not launch calc.exe" -skip:$skipNotWindows {
214214

215215
Import-Clixml -Path (Join-Path $PSScriptRoot "assets\CorruptedCim.clixml")
216-
216+
217217
# Wait up to 10 seconds for calc.exe to run
218218
$calcProc = $null
219219
$count = 0

0 commit comments

Comments
 (0)