[CommandNotFound]Upgrade to use PSGallery release and support arm64 (#32766)

* [CommandNotFound] Add support for upgrading the module

* upgrade module as a part of upgrade installation; actually set content in EnableModule.ps1

* Fix XAML style to pass CI

* Remove CmdNotFound project from sln as well

* Remove CmdNotFound psd1 file from installer

* More installer fixes

* UpgradeCommandNotFound runs after InstallFiles

* Fix NOTICE.md

* Fix custom action condition

* Pass install folder to the custom action

* Upgrade-Module --> Update-Module

* actually install the module

* spell

* verify updated scripts work; make necessary changes

---------

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
Carlos Zamora
2024-05-16 05:45:06 -07:00
committed by GitHub
parent 07ca6c8e62
commit e1832a0a4a
28 changed files with 188 additions and 540 deletions

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?include $(sys.CURRENTDIR)\Common.wxi?>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER" FileSource="$(var.BinDir)">
<!-- !Warning! Make sure to change Component Guid if you update the file list -->
<Component Id="Module_CmdNotFound" Win64="yes" Guid="80F648F2-29F6-4685-AED4-04DC1B6EE176">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdNotFound" Value="" KeyPath="yes"/>
</RegistryKey>
<File Source="$(var.BinDir)WinGetCommandNotFound.psd1" />
<!-- The dll files will be picked up by BaseApplications generateAllFileComponents.ps1-->
</Component>
</DirectoryRef>
<ComponentGroup Id="CmdNotFoundComponentGroup">
<ComponentRef Id="Module_CmdNotFound" />
</ComponentGroup>
</Fragment>
</Wix>

View File

@@ -18,7 +18,6 @@
<?define PastePlainProjectName="PastePlain"?>
<?define RegistryPreviewProjectName="RegistryPreview"?>
<?define PeekProjectName="Peek"?>
<?define CmdNotFoundProjectName="CmdNotFound"?>
<?define RepoDir="$(var.ProjectDir)..\..\" ?>
<?if $(var.Platform) = x64?>

View File

@@ -104,7 +104,6 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
<Compile Include="Awake.wxs" />
<Compile Include="BaseApplications.wxs" />
<Compile Include="CmdNotFound.wxs" />
<Compile Include="ColorPicker.wxs" />
<Compile Include="EnvironmentVariables.wxs" />
<Compile Include="FileExplorerPreview.wxs" />

View File

@@ -72,7 +72,6 @@
<ComponentGroupRef Id="VideoConferenceComponentGroup" />
<ComponentGroupRef Id="MouseWithoutBordersComponentGroup" />
<ComponentGroupRef Id="EnvironmentVariablesComponentGroup" />
<ComponentGroupRef Id="CmdNotFoundComponentGroup" />
<ComponentGroupRef Id="ResourcesComponentGroup" />
<ComponentGroupRef Id="WindowsAppSDKComponentGroup" />
@@ -135,6 +134,7 @@
<Custom Action="DetectPrevInstallPath" After="AppSearch" />
<Custom Action="SetLaunchPowerToysParam" Before="LaunchPowerToys" />
<Custom Action="SetUninstallCommandNotFoundParam" Before="UninstallCommandNotFound" />
<Custom Action="SetUpgradeCommandNotFoundParam" Before="UpgradeCommandNotFound" />
<Custom Action="SetApplyModulesRegistryChangeSetsParam" Before="ApplyModulesRegistryChangeSets" />
<Custom Action="SetUnApplyModulesRegistryChangeSetsParam" Before="UnApplyModulesRegistryChangeSets" />
<Custom Action="CheckGPO" After="InstallInitialize">
@@ -164,6 +164,9 @@
<Custom Action="UninstallCommandNotFound" Before="RemoveFiles">
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
<Custom Action="UpgradeCommandNotFound" After="InstallFiles">
WIX_UPGRADE_DETECTED
</Custom>
<Custom Action="UninstallServicesTask" After="InstallFinalize">
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
@@ -209,6 +212,10 @@
Property="UninstallCommandNotFound"
Value="[INSTALLFOLDER]" />
<CustomAction Id="SetUpgradeCommandNotFoundParam"
Property="UpgradeCommandNotFound"
Value="[INSTALLFOLDER]" />
<CustomAction Id="SetCreateWinAppSDKHardlinksParam"
Property="CreateWinAppSDKHardlinks"
Value="[INSTALLFOLDER]" />
@@ -269,6 +276,14 @@
BinaryKey="PTCustomActions"
DllEntry="UninstallCommandNotFoundModuleCA"
/>
<CustomAction Id="UpgradeCommandNotFound"
Return="ignore"
Impersonate="yes"
Execute="deferred"
BinaryKey="PTCustomActions"
DllEntry="UpgradeCommandNotFoundModuleCA"
/>
<CustomAction Id="TelemetryLogInstallSuccess"
Return="ignore"

View File

@@ -53,6 +53,7 @@
<RegistryValue Type="string" Name="CommandNotFound_Scripts" Value="" KeyPath="yes"/>
</RegistryKey>
<File Id="CommandNotFound_Scripts_EnableModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\EnableModule.ps1" />
<File Id="CommandNotFound_Scripts_UpgradeModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\UpgradeModule.ps1" />
<File Id="CommandNotFound_Scripts_DisableModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\DisableModule.ps1" />
<File Id="CommandNotFound_Scripts_CheckCmdNotFoundRequirements.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\CheckCmdNotFoundRequirements.ps1" />
<File Id="CommandNotFound_Scripts_InstallWinGetClientModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\InstallWinGetClientModule.ps1" />

View File

@@ -457,6 +457,30 @@ LExit:
return WcaFinalize(er);
}
UINT __stdcall UpgradeCommandNotFoundModuleCA(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
std::wstring installationFolder;
std::string command;
hr = WcaInitialize(hInstall, "UpgradeCommandNotFoundModule");
ExitOnFailure(hr, "Failed to initialize");
hr = getInstallFolder(hInstall, installationFolder);
ExitOnFailure(hr, "Failed to get installFolder.");
command = "pwsh.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\UpgradeModule.ps1" + "\"";
system(command.c_str());
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
UINT __stdcall UninstallServicesCA(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;

View File

@@ -23,4 +23,5 @@ EXPORTS
UnRegisterContextMenuPackagesCA
UninstallEmbeddedMSIXCA
UninstallServicesCA
UninstallCommandNotFoundModuleCA
UninstallCommandNotFoundModuleCA
UpgradeCommandNotFoundModuleCA