diff options
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg_Environment.cpp | 5 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index 94a672e2a..93953f92b 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -43,8 +43,7 @@ namespace vcpkg::Environment static std::wstring create_default_install_cmd(const vcpkg_paths& paths, const std::wstring& tool_name) { const fs::path script = paths.scripts / "fetchDependency.ps1"; - // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned - return Strings::wformat(LR"(powershell -ExecutionPolicy Bypass "%s" -Dependency %s)", script.native(), tool_name); + return System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name)); } void ensure_git_on_path(const vcpkg_paths& paths) @@ -103,7 +102,7 @@ namespace vcpkg::Environment static std::vector<std::string> get_VS2017_installation_instances(const vcpkg_paths& paths) { const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1"; - const std::wstring cmd = Strings::wformat(L"powershell -ExecutionPolicy Bypass %s", script.native()); + const std::wstring cmd = System::create_powershell_script_cmd(script); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd); Checks::check_exit(ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances"); return Strings::split(ec_data.output, "\n"); diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 679318768..9609d819b 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -49,6 +49,17 @@ namespace vcpkg::System return { ec, output }; } + std::wstring create_powershell_script_cmd(const fs::path& script_path) + { + return create_powershell_script_cmd(script_path, L""); + } + + std::wstring create_powershell_script_cmd(const fs::path& script_path, const std::wstring& args) + { + // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned + return Strings::wformat(LR"(powershell -ExecutionPolicy Bypass -Command "& {& '%s' %s}")", script_path.native(), args); + } + void print(const char* message) { fputs(message, stdout); |
