diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index be36df33c9..720a7d61e6 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -302,11 +302,6 @@ DECLARE_MESSAGE(AutomaticLinkingForMSBuildProjects, "", "All MSBuild C++ projects can now #include any installed libraries. Linking will be handled " "automatically. Installing new libraries will make them instantly available.") -DECLARE_MESSAGE(AutomaticLinkingForVS2017AndLater, - (), - "", - "Visual Studio 2017 and later can now #include any installed libraries. Linking will be handled " - "automatically. Installing new libraries will make them instantly available.") DECLARE_MESSAGE(AutoSettingEnvVar, (msg::env_var, msg::url), "An example of env_var is \"HTTP(S)_PROXY\"" @@ -1851,7 +1846,7 @@ DECLARE_MESSAGE(IntegrateInstallHelpLinux, (), "", "Makes installed packages ava DECLARE_MESSAGE(IntegrateInstallHelpWindows, (), "", - "Makes installed packages available user-wide. Requires admin privileges on first use") + "Makes installed packages available to MSBuild C++ projects for the current user") DECLARE_MESSAGE(IntegrateNonWindowsOnly, (msg::command_line), "", @@ -1870,7 +1865,6 @@ DECLARE_MESSAGE(IntegrateZshHelp, (), "'zsh' is a terminal program which should be unlocalized.", "Enable zsh tab-completion. Non-Windows only") -DECLARE_MESSAGE(IntegrationFailedVS2015, (), "", "Integration was not applied for Visual Studio 2015.") DECLARE_MESSAGE(InternalCICommand, (), "", @@ -2680,7 +2674,6 @@ DECLARE_MESSAGE(PortVersionControlMustBeANonNegativeInteger, (), "", "\"Port-Ver DECLARE_MESSAGE(PrebuiltPackages, (), "", "There are packages that have not been built. To build them run:") DECLARE_MESSAGE(PrecheckBinaryCache, (), "", "Checking the binary cache...") DECLARE_MESSAGE(PreviousDeclarationWasHere, (), "", "previous declaration was here") -DECLARE_MESSAGE(PreviousIntegrationFileRemains, (), "", "Previous integration file was not removed.") DECLARE_MESSAGE(ProgramReturnedNonzeroExitCode, (msg::tool_name, msg::exit_code), "The program's console output is appended after this.", @@ -2837,7 +2830,6 @@ DECLARE_MESSAGE(SystemApiErrorMessage, (msg::system_api, msg::exit_code, msg::error_msg), "", "calling {system_api} failed with {exit_code} ({error_msg})") -DECLARE_MESSAGE(SystemTargetsInstallFailed, (msg::path), "", "failed to install system targets file to {path}") DECLARE_MESSAGE( ToolHashMismatch, (msg::tool_name, msg::expected, msg::actual), diff --git a/include/vcpkg/commands.integrate.h b/include/vcpkg/commands.integrate.h index 7e71468d1c..3680404899 100644 --- a/include/vcpkg/commands.integrate.h +++ b/include/vcpkg/commands.integrate.h @@ -1,7 +1,5 @@ #pragma once -#include - #include #include @@ -15,7 +13,6 @@ namespace vcpkg extern const CommandMetadata CommandIntegrateMetadata; void command_integrate_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); - Optional find_targets_file_version(StringView contents); std::vector get_bash_source_completion_lines(StringView contents); struct ZshAutocomplete diff --git a/locales/messages.json b/locales/messages.json index 23972dcd92..31524048d7 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -204,7 +204,6 @@ "AutoSettingEnvVar": "-- Automatically setting {env_var} environment variables to \"{url}\".", "_AutoSettingEnvVar.comment": "An example of env_var is \"HTTP(S)_PROXY\"'--' at the beginning must be preserved An example of {env_var} is VCPKG_DEFAULT_TRIPLET. An example of {url} is https://github.com/microsoft/vcpkg.", "AutomaticLinkingForMSBuildProjects": "All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.", - "AutomaticLinkingForVS2017AndLater": "Visual Studio 2017 and later can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.", "AvailableHelpTopics": "Available help topics:", "AzUrlAssetCacheRequiresBaseUrl": "unexpected arguments: asset config 'azurl' requires a base url", "AzUrlAssetCacheRequiresLessThanFour": "unexpected arguments: asset config 'azurl' requires fewer than 4 arguments", @@ -1014,7 +1013,7 @@ "IntegrateFishHelp": "Enable fish tab-completion. Non-Windows only", "_IntegrateFishHelp.comment": "'fish' is a terminal program which should be unlocalized.", "IntegrateInstallHelpLinux": "Makes installed packages available user-wide", - "IntegrateInstallHelpWindows": "Makes installed packages available user-wide. Requires admin privileges on first use", + "IntegrateInstallHelpWindows": "Makes installed packages available to MSBuild C++ projects for the current user", "IntegrateNonWindowsOnly": "{command_line} is non-Windows-only and not supported on this system.", "_IntegrateNonWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.", "IntegratePowerShellHelp": "Enable PowerShell tab-completion. Windows-only", @@ -1024,7 +1023,6 @@ "_IntegrateWindowsOnly.comment": "An example of {command_line} is vcpkg install zlib.", "IntegrateZshHelp": "Enable zsh tab-completion. Non-Windows only", "_IntegrateZshHelp.comment": "'zsh' is a terminal program which should be unlocalized.", - "IntegrationFailedVS2015": "Integration was not applied for Visual Studio 2015.", "InternalCICommand": "vcpkg ci is an internal command which will change incompatibly or be removed at any time.", "InternalErrorMessageContact": "Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.", "InvalidArchitectureValue": "Invalid architecture: {value}. Expected one of: {expected}", @@ -1385,7 +1383,6 @@ "PrebuiltPackages": "There are packages that have not been built. To build them run:", "PrecheckBinaryCache": "Checking the binary cache...", "PreviousDeclarationWasHere": "previous declaration was here", - "PreviousIntegrationFileRemains": "Previous integration file was not removed.", "ProgramPathReturnedNonzeroExitCode": "failed with exit code {exit_code}", "_ProgramPathReturnedNonzeroExitCode.comment": "An example of {exit_code} is 127.", "ProgramReturnedNonzeroExitCode": "{tool_name} failed with exit code: ({exit_code}).", @@ -1468,8 +1465,6 @@ "_SynopsisHeader.comment": "Printed before a description of what a command does", "SystemApiErrorMessage": "calling {system_api} failed with {exit_code} ({error_msg})", "_SystemApiErrorMessage.comment": "An example of {system_api} is CreateProcessW. An example of {exit_code} is 127. An example of {error_msg} is File Not Found.", - "SystemTargetsInstallFailed": "failed to install system targets file to {path}", - "_SystemTargetsInstallFailed.comment": "An example of {path} is /foo/bar.", "ToRemovePackages": "To only remove outdated packages, run\n{command_name} remove --outdated", "_ToRemovePackages.comment": "An example of {command_name} is install.", "ToUpdatePackages": "To update these packages and all dependencies, run\n{command_name} upgrade'", diff --git a/src/vcpkg-test/integrate.cpp b/src/vcpkg-test/integrate.cpp index e9cd429a57..7ddc03254b 100644 --- a/src/vcpkg-test/integrate.cpp +++ b/src/vcpkg-test/integrate.cpp @@ -4,60 +4,6 @@ using namespace vcpkg; -TEST_CASE ("find_targets_file_version", "[integrate]") -{ - constexpr static StringLiteral DEFAULT_TARGETS_FILE = R"xml( - - - - $(LOCALAPPDATA)\vcpkg\vcpkg.user - - - - -)xml"; - - auto res = find_targets_file_version(DEFAULT_TARGETS_FILE); - REQUIRE(res.has_value()); - CHECK(*res.get() == 1); - - res = find_targets_file_version(""); - REQUIRE(res.has_value()); - CHECK(*res.get() == 12345); - - res = find_targets_file_version(""); - REQUIRE(res.has_value()); - CHECK(*res.get() == 1); - - res = find_targets_file_version(""); - REQUIRE(res.has_value()); - CHECK(*res.get() == 1); - - res = find_targets_file_version(" "); - REQUIRE(res.has_value()); - CHECK(*res.get() == 32); - - res = find_targets_file_version(""); - CHECK_FALSE(res.has_value()); - - res = find_targets_file_version(""); - CHECK_FALSE(res.has_value()); - - res = find_targets_file_version(""); - CHECK_FALSE(res.has_value()); - - res = find_targets_file_version(" "); - REQUIRE(res.has_value()); - CHECK(*res.get() == 1); - - res = find_targets_file_version(" "); - REQUIRE(res.has_value()); - CHECK(*res.get() == 1); - - res = find_targets_file_version(""); - CHECK_FALSE(res.has_value()); -} - TEST_CASE ("get_bash_source_completion_lines", "[integrate]") { const std::string default_bashrc = R"sh( diff --git a/src/vcpkg/commands.integrate.cpp b/src/vcpkg/commands.integrate.cpp index 8c2272e157..17b03762c4 100644 --- a/src/vcpkg/commands.integrate.cpp +++ b/src/vcpkg/commands.integrate.cpp @@ -1,5 +1,3 @@ -#include - #include #include @@ -19,34 +17,6 @@ namespace vcpkg { - Optional find_targets_file_version(StringView contents) - { - constexpr static StringLiteral VERSION_START = ""; - - auto first = contents.begin(); - const auto last = contents.end(); - for (;;) - { - first = Util::search_and_skip(first, last, VERSION_START); - if (first == last) - { - break; - } - auto version_end = Util::search(first, last, VERSION_END); - if (version_end == last) - { - break; - } - auto ver = Strings::strto({first, version_end}); - if (ver.has_value() && *ver.get() >= 0) - { - return ver; - } - } - return nullopt; - } - std::vector get_bash_source_completion_lines(StringView contents) { std::vector matches; @@ -125,17 +95,6 @@ namespace vcpkg target_path); } - static constexpr StringLiteral SystemTargetsShortcut = R"###( - - - - $(LOCALAPPDATA)\vcpkg\vcpkg.user - - - - -)###"; - static std::string create_nuget_targets_file_contents(const Path& msbuild_vcpkg_targets_file) { return fmt::format(R"###( @@ -204,102 +163,6 @@ namespace vcpkg } #endif // ^^^ _WIN32 -#if defined(_WIN32) - enum class ElevationPromptChoice - { - YES, - NO - }; - - static ElevationPromptChoice elevated_cmd_execute(const std::string& param) - { - SHELLEXECUTEINFOW sh_ex_info{}; - sh_ex_info.cbSize = sizeof(sh_ex_info); - sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS; - sh_ex_info.hwnd = nullptr; - sh_ex_info.lpVerb = L"runas"; - sh_ex_info.lpFile = L"cmd"; // Application to start - - auto wparam = Strings::to_utf16(param); - sh_ex_info.lpParameters = wparam.c_str(); // Additional parameters - sh_ex_info.lpDirectory = nullptr; - sh_ex_info.nShow = SW_HIDE; - sh_ex_info.hInstApp = nullptr; - - if (!ShellExecuteExW(&sh_ex_info)) - { - return ElevationPromptChoice::NO; - } - if (sh_ex_info.hProcess == nullptr) - { - return ElevationPromptChoice::NO; - } - WaitForSingleObject(sh_ex_info.hProcess, INFINITE); - CloseHandle(sh_ex_info.hProcess); - return ElevationPromptChoice::YES; - } -#endif // ^^^ _WIN32 - -#if defined(_WIN32) - static bool integrate_install_msbuild14(const Filesystem& fs) - { - Path OLD_SYSTEM_TARGET_FILES[] = { - get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) / - "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets", - get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) / - "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"}; - - Path SYSTEM_WIDE_TARGETS_FILE = get_program_files_32_bit().value_or_exit(VCPKG_LINE_INFO) / - "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props"; - - // TODO: This block of code should eventually be removed - for (auto&& old_system_wide_targets_file : OLD_SYSTEM_TARGET_FILES) - { - if (fs.exists(old_system_wide_targets_file, IgnoreErrors{})) - { - const std::string param = fmt::format(R"(/d /c "DEL "{}" /Q > nul")", old_system_wide_targets_file); - const ElevationPromptChoice user_choice = elevated_cmd_execute(param); - switch (user_choice) - { - case ElevationPromptChoice::YES: break; - case ElevationPromptChoice::NO: msg::println_warning(msgPreviousIntegrationFileRemains); break; - default: Checks::unreachable(VCPKG_LINE_INFO); - } - } - } - - std::error_code ec; - std::string system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE, ec); - if (!ec) - { - auto opt = find_targets_file_version(system_wide_file_contents); - if (opt.value_or(0) >= 1) - { - return true; - } - } - - const auto tmp_dir = fs.create_or_get_temp_directory(VCPKG_LINE_INFO); - const auto sys_src_path = tmp_dir / "vcpkg.system.targets"; - fs.write_contents(sys_src_path, SystemTargetsShortcut, VCPKG_LINE_INFO); - - const std::string param = fmt::format(R"(/d /c "mkdir "{}" & copy "{}" "{}" /Y > nul")", - SYSTEM_WIDE_TARGETS_FILE.parent_path(), - sys_src_path, - SYSTEM_WIDE_TARGETS_FILE); - elevated_cmd_execute(param); - fs.remove_all(tmp_dir, VCPKG_LINE_INFO); - - if (!fs.exists(SYSTEM_WIDE_TARGETS_FILE, IgnoreErrors{})) - { - msg::println_warning(msg::format(msgSystemTargetsInstallFailed, msg::path = SYSTEM_WIDE_TARGETS_FILE)); - return false; - } - - return true; - } -#endif // ^^^ _WIN32 - static void integrate_install(const VcpkgPaths& paths) { auto& fs = paths.get_filesystem(); @@ -319,13 +182,6 @@ namespace vcpkg create_appdata_shortcut(paths.buildsystems_msbuild_targets), VCPKG_LINE_INFO); - if (!integrate_install_msbuild14(fs)) - { - message.append_raw("\n\n").append(msgAutomaticLinkingForVS2017AndLater); - msg::println(message); - Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgIntegrationFailedVS2015); - } - message.append_raw("\n\n").append(msgAutomaticLinkingForMSBuildProjects); #endif // ^^^ _WIN32