diff --git a/installer/MSIX/PackagingLayout.xml b/installer/MSIX/PackagingLayout.xml index e028d2ccab..ef63b83964 100644 --- a/installer/MSIX/PackagingLayout.xml +++ b/installer/MSIX/PackagingLayout.xml @@ -1,7 +1,7 @@ - + diff --git a/installer/MSIX/generate_self_sign_cert.ps1 b/installer/MSIX/generate_self_sign_cert.ps1 new file mode 100644 index 0000000000..2d9c65490b --- /dev/null +++ b/installer/MSIX/generate_self_sign_cert.ps1 @@ -0,0 +1,5 @@ +$expirationDate = {Get-Date}.Invoke().AddYears(5) +$pass = ConvertTo-SecureString -String "12345" -Force -AsPlainText +$thumbprint = (New-SelfSignedCertificate -notafter $expirationDate -Type CodeSigningCert -Subject "CN=Microsoft Corporation" -FriendlyName "PowerToys Test Certificate" -KeyDescription "PowerToys Test Certificate" -KeyFriendlyName "PowerToys Test Key" -KeyUsage "DigitalSignature" -CertStoreLocation Cert:\LocalMachine\My).Thumbprint +Export-PfxCertificate -Cert cert:\LocalMachine\My\$thumbprint -FilePath PowerToys_TemporaryKey.pfx -Password $pass +Import-PfxCertificate -CertStoreLocation Cert:\LocalMachine\Root -FilePath PowerToys_TemporaryKey.pfx -Password $pass diff --git a/installer/MSIX/msix_reinstall.ps1 b/installer/MSIX/msix_reinstall.ps1 new file mode 100644 index 0000000000..68a4f21576 --- /dev/null +++ b/installer/MSIX/msix_reinstall.ps1 @@ -0,0 +1,6 @@ +taskkill /f /im explorer.exe +Get-AppxPackage -Name 'PowerToys' | select -ExpandProperty "PackageFullName" | Remove-AppxPackage +makeappx build /v /overwrite /f PackagingLayout.xml /id "PowerToys-x64" /op bin\ +signtool sign /debug /a /fd SHA256 /f PowerToys_TemporaryKey.pfx /p 12345 bin\PowerToys-x64.msix +Add-AppxPackage .\bin\PowerToys-x64.msix +start $Env:windir\explorer.exe \ No newline at end of file diff --git a/installer/MSIX/reinstall.ps1 b/installer/MSIX/reinstall.ps1 deleted file mode 100644 index ab1f129fe4..0000000000 --- a/installer/MSIX/reinstall.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$name='PowerToys' -taskkill /f /im explorer.exe -Get-AppxPackage -Name $name | select -ExpandProperty "PackageFullName" | Remove-AppxPackage -makeappx build /v /overwrite /f PackagingLayout.xml /id "x64" /op bin\ -signtool sign /debug /a /fd SHA256 /f PowerToysTestKey.pfx /p 12345 bin\x64.msix -Add-AppxPackage .\bin\x64.msix -start $Env:windir\explorer.exe \ No newline at end of file diff --git a/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj b/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj index 1c5fc403a3..fe20fba44d 100644 --- a/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj +++ b/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj @@ -90,10 +90,6 @@ MachineX64 HighestAvailable - - cd $(SolutionDir)MSIX && makeappx build /overwrite /f PackagingLayout.xml /id x64 /op bin\ && signtool sign /a /fd SHA256 /f PowerToysTestKey.pfx /p 12345 bin\x64.msix - $(SolutionDir)MSIX\bin\x64.msix - diff --git a/installer/README.md b/installer/README.md index 4717da66ce..e5821d6dc9 100644 --- a/installer/README.md +++ b/installer/README.md @@ -7,10 +7,14 @@ * The resulting installer will be built to `PowerToysSetup\bin\Release\PowerToysSetup.msi`. ## Building and installing self-signed PowerToys MSIX package -* Make sure you've built correct `powertoys.sln` configuration -* Add `PowerToysTestKey.pfx` to the [TRCA store](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/trusted-root-certification-authorities-certificate-store) -* Execute `reinstall.ps1` from the devenv powershell: -## Removing all current PowerToys installations +For the first-time installation, you should generate a self-signed certificate and add it to the [TRCA store](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/trusted-root-certification-authorities-certificate-store). That could be done by simply running ` +generate_self_sign_cert.ps1` from a powershell admin. After that: + +* Make sure you've built the `Release` configuration of `powertoys.sln` +* Launch `msix_reinstall.ps1` from the devenv powershell + +`msix_reinstall.ps1` removes the current PowerToys installation, restarts explorer.exe (to update PowerRename shell extension), builds `PowerToys-x64.msix` package, signs it with a PowerToys_TemporaryKey.pfx, and finally installs it. +## Removing all .msi/.msix PowerToys installations ```ps $name='PowerToys' Get-AppxPackage -Name $name | select -ExpandProperty "PackageFullName" | Remove-AppxPackage diff --git a/src/common/winstore.h b/src/common/winstore.h index 88916ee10d..5c33639b4f 100644 --- a/src/common/winstore.h +++ b/src/common/winstore.h @@ -1,3 +1,3 @@ #pragma once -bool running_as_packaged(); \ No newline at end of file +bool running_as_packaged();