Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ For aliases requested through `--rename`, `Commands`, or `PortableCommandAlias`,
This change resolves alias failures in non-symlinked scenarios, including cases where WinGet adds the install directory to `PATH` instead of creating links.
Because the alias is now created as an executable hardlink in the install location, command aliases remain available and consistent even when symlink creation is skipped.

### PowerShell `-WhatIf`

PowerShell package commands now honor `-WhatIf` and do not perform package operations during preview.

### Minor Bug Fixes
* Fixed REST search results bypassing locally verifiable package filters and selectors. Extra manifests are retrieved only for complete source result sets of three or fewer packages. Normalized name/publisher criteria remain unvalidated client-side.
* Fixed installed-package matching incorrectly combining names and publishers from different manifest entries.
Expand Down
11 changes: 5 additions & 6 deletions src/PowerShell/CommonFiles/PowerShellCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,12 @@ internal void SetVariable(string variableName, object value)
/// <returns>If the operation should continue.</returns>
internal bool ShouldProcess(string target)
{
// If not on the main thread just continue.
if (this.pwshThread != Thread.CurrentThread)
bool shouldProcess = false;
this.ExecuteInPowerShellThread(() =>
{
return true;
}

return this.psCmdlet.ShouldProcess(target);
shouldProcess = this.psCmdlet.ShouldProcess(target);
});
return shouldProcess;
}

private void Complete()
Expand Down
39 changes: 39 additions & 0 deletions src/PowerShell/tests/Microsoft.WinGet.Client.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,34 @@ Describe 'Install|Update|Uninstall-WinGetPackage' {
}
}

It 'Does not install with WhatIf' {
$result = Install-WinGetPackage -Id AppInstallerTest.TestExeInstaller -Version '1.0.0.0' -WhatIf

$result | Should -BeNullOrEmpty
(Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller -ErrorAction SilentlyContinue) | Should -BeNullOrEmpty
}

It 'Install by Id' {
$result = Install-WinGetPackage -Id AppInstallerTest.TestExeInstaller -Version '1.0.0.0'
Validate-WinGetPackageOperationResult $result $expectedExeInstallerResult 'install'
}

It 'Does not update with WhatIf' {
$installedVersion = (Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller).InstalledVersion
$result = Update-WinGetPackage -Id AppInstallerTest.TestExeInstaller -WhatIf

$result | Should -BeNullOrEmpty
(Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller).InstalledVersion | Should -Be $installedVersion
}

It 'Does not uninstall with WhatIf' {
$installedVersion = (Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller).InstalledVersion
$result = Uninstall-WinGetPackage -Id AppInstallerTest.TestExeInstaller -WhatIf

$result | Should -BeNullOrEmpty
(Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller).InstalledVersion | Should -Be $installedVersion
}

It 'Install by exact Name and Version' {
$result = Install-WinGetPackage -Name TestPortableExe -Version '2.0.0.0' -MatchOption Equals
Validate-WinGetPackageOperationResult $result $expectedPortableInstallerResult 'install'
Expand Down Expand Up @@ -369,6 +392,14 @@ Describe 'Install|Repair|Uninstall-WinGetPackage' {
Validate-WinGetPackageOperationResult $result $expectedResult 'install'
}

It 'Does not repair MSIX with WhatIf' {
$installedVersion = (Get-WinGetPackage -Id AppInstallerTest.TestMsixInstaller).InstalledVersion
$result = Repair-WinGetPackage -Id AppInstallerTest.TestMsixInstaller -WhatIf

$result | Should -BeNullOrEmpty
(Get-WinGetPackage -Id AppInstallerTest.TestMsixInstaller).InstalledVersion | Should -Be $installedVersion
}

It 'Repair MSIX By Id' {
$result = Repair-WinGetPackage -Id AppInstallerTest.TestMsixInstaller
Validate-WinGetPackageOperationResult $result $expectedResult 'repair'
Expand Down Expand Up @@ -594,6 +625,14 @@ Describe 'Export-WinGetPackage' {
AddTestSource
}

It 'Does not download with WhatIf' {
$testDirectory = GetRandomTestDirectory
$result = Export-WinGetPackage -Id AppInstallerTest.TestExeInstaller -Version '1.0.0.0' -DownloadDirectory $testDirectory -WhatIf

$result | Should -BeNullOrEmpty
Test-Path -Path $testDirectory | Should -Be $false
}

It 'Download by Id' {
$testDirectory = GetRandomTestDirectory
$result = Export-WinGetPackage -Id AppInstallerTest.TestExeInstaller -Version '1.0.0.0' -DownloadDirectory $testDirectory
Expand Down
Loading