mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Auto-update] Turn off on Windows < 1903 (#10240)
This commit is contained in:
@@ -158,4 +158,7 @@
|
|||||||
<data name="NEWER_VERSION_ERROR" xml:space="preserve">
|
<data name="NEWER_VERSION_ERROR" xml:space="preserve">
|
||||||
<value>A newer version is already installed.</value>
|
<value>A newer version is already installed.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="OLD_WINDOWS_ERROR" xml:space="preserve">
|
||||||
|
<value>PowerToys requires Windows 10 version 1903 (May 2019 Update) or newer to run.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@@ -152,8 +152,6 @@ int Bootstrapper(HINSTANCE hInstance)
|
|||||||
const auto installDirArg = cmdArgs["install_dir"].as<std::string>();
|
const auto installDirArg = cmdArgs["install_dir"].as<std::string>();
|
||||||
const bool extract_msi_only = cmdArgs["extract_msi"].as<bool>();
|
const bool extract_msi_only = cmdArgs["extract_msi"].as<bool>();
|
||||||
|
|
||||||
spdlog::level::level_enum severity = spdlog::level::off;
|
|
||||||
|
|
||||||
std::wstring installFolderProp;
|
std::wstring installFolderProp;
|
||||||
if (!installDirArg.empty())
|
if (!installDirArg.empty())
|
||||||
{
|
{
|
||||||
@@ -185,6 +183,7 @@ int Bootstrapper(HINSTANCE hInstance)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spdlog::level::level_enum severity = spdlog::level::off;
|
||||||
if (logLevel == "debug")
|
if (logLevel == "debug")
|
||||||
{
|
{
|
||||||
severity = spdlog::level::debug;
|
severity = spdlog::level::debug;
|
||||||
@@ -197,6 +196,16 @@ int Bootstrapper(HINSTANCE hInstance)
|
|||||||
SetupLogger(logDir, severity);
|
SetupLogger(logDir, severity);
|
||||||
spdlog::debug("PowerToys Bootstrapper is launched\nnoFullUI: {}\nsilent: {}\nno_start_pt: {}\nskip_dotnet_install: {}\nlog_level: {}\ninstall_dir: {}\nextract_msi: {}\n", noFullUI, g_Silent, noStartPT, skipDotnetInstall, logLevel, installDirArg, extract_msi_only);
|
spdlog::debug("PowerToys Bootstrapper is launched\nnoFullUI: {}\nsilent: {}\nno_start_pt: {}\nskip_dotnet_install: {}\nlog_level: {}\ninstall_dir: {}\nextract_msi: {}\n", noFullUI, g_Silent, noStartPT, skipDotnetInstall, logLevel, installDirArg, extract_msi_only);
|
||||||
|
|
||||||
|
const VersionHelper myVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
||||||
|
|
||||||
|
// Do not support installing on Windows < 1903
|
||||||
|
if (myVersion >= VersionHelper{0, 36, 0} && updating::is_old_windows_version())
|
||||||
|
{
|
||||||
|
ShowMessageBoxError(IDS_OLD_WINDOWS_ERROR);
|
||||||
|
spdlog::error("PowerToys {} requires at least Windows 1903 to run.", myVersion.toString());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// If a user requested an MSI -> extract it and exit
|
// If a user requested an MSI -> extract it and exit
|
||||||
if (extract_msi_only)
|
if (extract_msi_only)
|
||||||
{
|
{
|
||||||
@@ -212,7 +221,6 @@ int Bootstrapper(HINSTANCE hInstance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there's a newer version installed
|
// Check if there's a newer version installed
|
||||||
const VersionHelper myVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
|
||||||
const auto installedVersion = updating::get_installed_powertoys_version();
|
const auto installedVersion = updating::get_installed_powertoys_version();
|
||||||
if (installedVersion && *installedVersion >= myVersion)
|
if (installedVersion && *installedVersion >= myVersion)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "installer.h"
|
#include "installer.h"
|
||||||
#include <common/version/version.h>
|
#include <common/version/version.h>
|
||||||
#include <common/notifications/notifications.h>
|
#include <common/notifications/notifications.h>
|
||||||
|
#include <common/utils/os-detect.h>
|
||||||
#include "utils/winapi_error.h"
|
#include "utils/winapi_error.h"
|
||||||
|
|
||||||
namespace // Strings in this namespace should not be localized
|
namespace // Strings in this namespace should not be localized
|
||||||
@@ -192,4 +193,8 @@ namespace updating
|
|||||||
co_return false;
|
co_return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_old_windows_version()
|
||||||
|
{
|
||||||
|
return !Is19H1OrHigher();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,6 @@ namespace updating
|
|||||||
|
|
||||||
std::optional<VersionHelper> get_installed_powertoys_version();
|
std::optional<VersionHelper> get_installed_powertoys_version();
|
||||||
std::future<bool> uninstall_previous_msix_version_async();
|
std::future<bool> uninstall_previous_msix_version_async();
|
||||||
|
|
||||||
|
bool is_old_windows_version();
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,10 @@
|
|||||||
#include "notifications.h"
|
#include "notifications.h"
|
||||||
#include "updating.h"
|
#include "updating.h"
|
||||||
|
|
||||||
#include <common/utils/json.h>
|
|
||||||
#include <common/SettingsAPI/settings_helpers.h>
|
|
||||||
#include <common/notifications/notifications.h>
|
#include <common/notifications/notifications.h>
|
||||||
|
#include <common/SettingsAPI/settings_helpers.h>
|
||||||
|
#include <common/utils/json.h>
|
||||||
|
#include <common/utils/os-detect.h>
|
||||||
|
|
||||||
namespace // Strings in this namespace should not be localized
|
namespace // Strings in this namespace should not be localized
|
||||||
{
|
{
|
||||||
@@ -68,12 +69,17 @@ namespace updating
|
|||||||
{
|
{
|
||||||
co_return nonstd::make_unexpected(strings.GITHUB_NEW_VERSION_USING_LOCAL_BUILD_ERROR);
|
co_return nonstd::make_unexpected(strings.GITHUB_NEW_VERSION_USING_LOCAL_BUILD_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
http::HttpClient client;
|
http::HttpClient client;
|
||||||
json::JsonObject release_object;
|
json::JsonObject release_object;
|
||||||
const VersionHelper current_version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
const VersionHelper current_version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
||||||
VersionHelper github_version = current_version;
|
VersionHelper github_version = current_version;
|
||||||
|
|
||||||
|
// On a <1903 system, block updates to 0.36+
|
||||||
|
const bool blockNonPatchReleases = current_version.major == 0 && current_version.minor == 35 && !Is19H1OrHigher();
|
||||||
|
|
||||||
if (prerelease)
|
if (prerelease)
|
||||||
{
|
{
|
||||||
const auto body = co_await client.request(Uri{ ALL_RELEASES_ENDPOINT });
|
const auto body = co_await client.request(Uri{ ALL_RELEASES_ENDPOINT });
|
||||||
@@ -102,6 +108,11 @@ namespace updating
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blockNonPatchReleases && github_version >= VersionHelper{ 0, 36, 0 })
|
||||||
|
{
|
||||||
|
co_return version_up_to_date{};
|
||||||
|
}
|
||||||
|
|
||||||
if (github_version <= current_version)
|
if (github_version <= current_version)
|
||||||
{
|
{
|
||||||
co_return version_up_to_date{};
|
co_return version_up_to_date{};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <winrt/Windows.Foundation.Metadata.h>
|
#include <winrt/Windows.Foundation.Metadata.h>
|
||||||
|
|
||||||
// The following three helper functions determine if the user has a build version higher than or equal to 19h1, as that is a requirement for xaml islands
|
// The following three helper functions determine if the user has a build version higher than or equal to 19h1 (aka 1903), as that is a requirement for xaml islands
|
||||||
// Source : Microsoft-ui-xaml github
|
// Source : Microsoft-ui-xaml github
|
||||||
// Link: https://github.com/microsoft/microsoft-ui-xaml/blob/c045cde57c5c754683d674634a0baccda34d58c4/dev/dll/SharedHelpers.cpp
|
// Link: https://github.com/microsoft/microsoft-ui-xaml/blob/c045cde57c5c754683d674634a0baccda34d58c4/dev/dll/SharedHelpers.cpp
|
||||||
template<uint16_t APIVersion>
|
template<uint16_t APIVersion>
|
||||||
|
|||||||
@@ -39,3 +39,14 @@ std::wstring VersionHelper::toWstring() const
|
|||||||
result += std::to_wstring(revision);
|
result += std::to_wstring(revision);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VersionHelper::toString() const
|
||||||
|
{
|
||||||
|
std::string result{ "v" };
|
||||||
|
result += std::to_string(major);
|
||||||
|
result += '.';
|
||||||
|
result += std::to_string(minor);
|
||||||
|
result += '.';
|
||||||
|
result += std::to_string(revision);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ struct VersionHelper
|
|||||||
size_t revision;
|
size_t revision;
|
||||||
|
|
||||||
std::wstring toWstring() const;
|
std::wstring toWstring() const;
|
||||||
|
std::string toString() const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user