diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h index 51ea728c346..f35b477cdb5 100644 --- a/toolsrc/include/vcpkg/base/system.process.h +++ b/toolsrc/include/vcpkg/base/system.process.h @@ -40,7 +40,7 @@ namespace vcpkg::System const Environment& get_clean_environment(); Environment get_modified_clean_environment(const std::unordered_map& extra_env, - const std::string& prepend_to_path = {}); + const std::string& prepend_to_path = {}, const std::string& append_to_path = {}); int cmd_execute(const ZStringView cmd_line, const Environment& env = {}); int cmd_execute_clean(const ZStringView cmd_line); diff --git a/toolsrc/src/vcpkg/base/system.process.cpp b/toolsrc/src/vcpkg/base/system.process.cpp index 5f34ace2a7f..ed2e0c2cdf4 100644 --- a/toolsrc/src/vcpkg/base/system.process.cpp +++ b/toolsrc/src/vcpkg/base/system.process.cpp @@ -190,7 +190,7 @@ namespace vcpkg #if defined(_WIN32) Environment System::get_modified_clean_environment(const std::unordered_map& extra_env, - const std::string& prepend_to_path) + const std::string& prepend_to_path, const std::string& append_to_path) { static const std::string SYSTEM_ROOT = get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO); static const std::string SYSTEM_32 = SYSTEM_ROOT + R"(\system32)"; @@ -291,6 +291,10 @@ namespace vcpkg if (extra_env.find("PATH") != extra_env.end()) new_path += Strings::format(";%s", extra_env.find("PATH")->second); + + if(!append_to_path.empty()) + new_path += Strings::format(";%s", append_to_path); + env_cstr.append(Strings::to_utf16(new_path)); env_cstr.push_back(L'\0'); env_cstr.append(L"VSLANG=1033"); diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 68b6085d556..1e65f6c12a0 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -470,6 +470,7 @@ namespace vcpkg::Build auto&& scfl = action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO); std::string prepend_to_path; + std::string append_to_path; #if defined(_WIN32) const fs::path& powershell_exe_path = paths.get_tool_exe("powershell-core"); @@ -489,7 +490,7 @@ namespace vcpkg::Build fs::path git_ssh_exe_path = git_ssh_search_path / "usr" / "bin" / "ssh.exe"; if (fs.exists(git_ssh_exe_path)) { - prepend_to_path += git_ssh_exe_path.parent_path().u8string() + ";"; + append_to_path += git_ssh_exe_path.parent_path().u8string() + ";"; break; } } @@ -532,7 +533,7 @@ namespace vcpkg::Build const auto& env = build_env_cache.get_lazy({&base_env, build_env_cmd}, [&]() { auto clean_env = - System::get_modified_clean_environment(base_env, prepend_to_path); + System::get_modified_clean_environment(base_env, prepend_to_path, append_to_path); if (build_env_cmd.empty()) return clean_env; else