From d86d9727f6802a5f642e550db13e97a9a2ea8a29 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 31 Aug 2017 18:02:12 -0700 Subject: Function naming convention --- toolsrc/src/commands_integrate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index c5942f9fc..fce9e4121 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -9,10 +9,10 @@ namespace vcpkg::Commands::Integrate { static const std::array old_system_target_files = { - System::get_ProgramFiles_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets", - System::get_ProgramFiles_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"}; + System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets", + System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"}; static const fs::path system_wide_targets_file = - System::get_ProgramFiles_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props"; + System::get_program_files_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props"; static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept { -- cgit v1.2.3 From 81c9445376e677aa04d33b125917a61020cafda9 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 31 Aug 2017 18:05:58 -0700 Subject: example -> EXAMPLE --- toolsrc/src/commands_integrate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index fce9e4121..b0ce5edee 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -317,10 +317,10 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { - static const std::string example = Strings::format("Commands:\n" + static const std::string EXAMPLE = Strings::format("Commands:\n" "%s", INTEGRATE_COMMAND_HELPSTRING); - args.check_exact_arg_count(1, example); + args.check_exact_arg_count(1, EXAMPLE); args.check_and_get_optional_command_arguments({}); if (args.command_arguments[0] == "install") -- cgit v1.2.3 From 775dc8ce4017395406f9699676b1e8a117afcac5 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 31 Aug 2017 18:22:56 -0700 Subject: [vcpkg integrate] Naming convention fixes --- toolsrc/src/commands_integrate.cpp | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index b0ce5edee..abfb676da 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -8,10 +8,10 @@ namespace vcpkg::Commands::Integrate { - static const std::array old_system_target_files = { + static const std::array OLD_SYSTEM_TARGET_FILES = { System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets", System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"}; - static const fs::path system_wide_targets_file = + static const fs::path SYSTEM_WIDE_TARGETS_FILE = System::get_program_files_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props"; static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept @@ -82,7 +82,7 @@ namespace vcpkg::Commands::Integrate const std::string& nuget_id, const std::string& nupkg_version) { - static constexpr auto content_template = R"( + static constexpr auto CONTENT_TEMPLATE = R"( @NUGET_ID@ @@ -99,7 +99,7 @@ namespace vcpkg::Commands::Integrate )"; - std::string content = std::regex_replace(content_template, std::regex("@NUGET_ID@"), nuget_id); + std::string content = std::regex_replace(CONTENT_TEMPLATE, std::regex("@NUGET_ID@"), nuget_id); content = std::regex_replace(content, std::regex("@VCPKG_DIR@"), vcpkg_root_dir.string()); content = std::regex_replace(content, std::regex("@VERSION@"), nupkg_version); return content; @@ -113,36 +113,36 @@ namespace vcpkg::Commands::Integrate static ElevationPromptChoice elevated_cmd_execute(const std::string& param) { - SHELLEXECUTEINFO shExInfo = {0}; - shExInfo.cbSize = sizeof(shExInfo); - shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - shExInfo.hwnd = nullptr; - shExInfo.lpVerb = "runas"; - shExInfo.lpFile = "cmd"; // Application to start - - shExInfo.lpParameters = param.c_str(); // Additional parameters - shExInfo.lpDirectory = nullptr; - shExInfo.nShow = SW_HIDE; - shExInfo.hInstApp = nullptr; - - if (!ShellExecuteExA(&shExInfo)) + SHELLEXECUTEINFO sh_ex_info = {0}; + sh_ex_info.cbSize = sizeof(sh_ex_info); + sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS; + sh_ex_info.hwnd = nullptr; + sh_ex_info.lpVerb = "runas"; + sh_ex_info.lpFile = "cmd"; // Application to start + + sh_ex_info.lpParameters = param.c_str(); // Additional parameters + sh_ex_info.lpDirectory = nullptr; + sh_ex_info.nShow = SW_HIDE; + sh_ex_info.hInstApp = nullptr; + + if (!ShellExecuteExA(&sh_ex_info)) { return ElevationPromptChoice::NO; } - if (shExInfo.hProcess == nullptr) + if (sh_ex_info.hProcess == nullptr) { return ElevationPromptChoice::NO; } - WaitForSingleObject(shExInfo.hProcess, INFINITE); - CloseHandle(shExInfo.hProcess); + WaitForSingleObject(sh_ex_info.hProcess, INFINITE); + CloseHandle(sh_ex_info.hProcess); return ElevationPromptChoice::YES; } static fs::path get_appdata_targets_path() { - static const fs::path local_app_data = + static const fs::path LOCAL_APP_DATA = fs::path(System::get_environment_variable(L"LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO)); - return local_app_data / "vcpkg" / "vcpkg.user.targets"; + return LOCAL_APP_DATA / "vcpkg" / "vcpkg.user.targets"; } static void integrate_install(const VcpkgPaths& paths) @@ -150,7 +150,7 @@ namespace vcpkg::Commands::Integrate auto& fs = paths.get_filesystem(); // TODO: This block of code should eventually be removed - for (auto&& old_system_wide_targets_file : old_system_target_files) + for (auto&& old_system_wide_targets_file : OLD_SYSTEM_TARGET_FILES) { if (fs.exists(old_system_wide_targets_file)) { @@ -174,7 +174,7 @@ namespace vcpkg::Commands::Integrate fs.create_directory(tmp_dir, ec); bool should_install_system = true; - const Expected system_wide_file_contents = fs.read_contents(system_wide_targets_file); + const Expected system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE); if (auto contents_data = system_wide_file_contents.get()) { std::regex re(R"###()###"); @@ -193,9 +193,9 @@ namespace vcpkg::Commands::Integrate fs.write_contents(sys_src_path, create_system_targets_shortcut()); const std::string param = Strings::format(R"(/c mkdir "%s" & copy "%s" "%s" /Y > nul)", - system_wide_targets_file.parent_path().string(), + SYSTEM_WIDE_TARGETS_FILE.parent_path().string(), sys_src_path.string(), - system_wide_targets_file.string()); + SYSTEM_WIDE_TARGETS_FILE.string()); ElevationPromptChoice user_choice = elevated_cmd_execute(param); switch (user_choice) { @@ -207,9 +207,9 @@ namespace vcpkg::Commands::Integrate } Checks::check_exit(VCPKG_LINE_INFO, - fs.exists(system_wide_targets_file), + fs.exists(SYSTEM_WIDE_TARGETS_FILE), "Error: failed to copy targets file to %s", - system_wide_targets_file.string()); + SYSTEM_WIDE_TARGETS_FILE.string()); } const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; -- cgit v1.2.3 From dff6b22b430d27fac6239076d7511aaa5df6c9ca Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 31 Aug 2017 18:24:44 -0700 Subject: [vcpkg integrate] Change regex to static const, add missing consts --- toolsrc/src/commands_integrate.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index abfb676da..1bf26910c 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -156,7 +156,7 @@ namespace vcpkg::Commands::Integrate { const std::string param = Strings::format(R"(/c DEL "%s" /Q > nul)", old_system_wide_targets_file.string()); - ElevationPromptChoice user_choice = elevated_cmd_execute(param); + const ElevationPromptChoice user_choice = elevated_cmd_execute(param); switch (user_choice) { case ElevationPromptChoice::YES: break; @@ -175,14 +175,14 @@ namespace vcpkg::Commands::Integrate bool should_install_system = true; const Expected system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE); - if (auto contents_data = system_wide_file_contents.get()) + static const std::regex RE(R"###()###"); + if (const auto contents_data = system_wide_file_contents.get()) { - std::regex re(R"###()###"); std::match_results match; - auto found = std::regex_search(*contents_data, match, re); + const auto found = std::regex_search(*contents_data, match, RE); if (found) { - int ver = atoi(match[1].str().c_str()); + const int ver = atoi(match[1].str().c_str()); if (ver >= 1) should_install_system = false; } } @@ -196,7 +196,7 @@ namespace vcpkg::Commands::Integrate SYSTEM_WIDE_TARGETS_FILE.parent_path().string(), sys_src_path.string(), SYSTEM_WIDE_TARGETS_FILE.string()); - ElevationPromptChoice user_choice = elevated_cmd_execute(param); + const ElevationPromptChoice user_choice = elevated_cmd_execute(param); switch (user_choice) { case ElevationPromptChoice::YES: break; @@ -217,7 +217,7 @@ namespace vcpkg::Commands::Integrate create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.string())); auto appdata_dst_path = get_appdata_targets_path(); - auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec); + const auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec); if (!rc || ec) { @@ -245,7 +245,7 @@ namespace vcpkg::Commands::Integrate const fs::path path = get_appdata_targets_path(); std::error_code ec; - bool was_deleted = fs.remove(path, ec); + const bool was_deleted = fs.remove(path, ec); Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %d", ec.message()); -- cgit v1.2.3 From 20d911a91508c16bd01272ae94a3ca239a4d984e Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 2 Oct 2017 13:57:55 -0700 Subject: [vcpkg] Fix use of UNICODE-sensitive Windows APIs --- toolsrc/src/commands_integrate.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index 1bf26910c..fd2f11294 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -113,19 +113,20 @@ namespace vcpkg::Commands::Integrate static ElevationPromptChoice elevated_cmd_execute(const std::string& param) { - SHELLEXECUTEINFO sh_ex_info = {0}; + SHELLEXECUTEINFOW sh_ex_info = {0}; sh_ex_info.cbSize = sizeof(sh_ex_info); sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS; sh_ex_info.hwnd = nullptr; - sh_ex_info.lpVerb = "runas"; - sh_ex_info.lpFile = "cmd"; // Application to start + sh_ex_info.lpVerb = L"runas"; + sh_ex_info.lpFile = L"cmd"; // Application to start - sh_ex_info.lpParameters = param.c_str(); // Additional parameters + 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 (!ShellExecuteExA(&sh_ex_info)) + if (!ShellExecuteExW(&sh_ex_info)) { return ElevationPromptChoice::NO; } -- cgit v1.2.3 From e17de99599a2f114faab1bb4821fbaad4d266c95 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Fri, 13 Oct 2017 18:37:41 -0700 Subject: [vcpkg] Re-layout all files using new organization scheme. All filenames and directories are lowercase. Use dots for namespace separation. --- toolsrc/src/commands_integrate.cpp | 342 ------------------------------------- 1 file changed, 342 deletions(-) delete mode 100644 toolsrc/src/commands_integrate.cpp (limited to 'toolsrc/src/commands_integrate.cpp') diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp deleted file mode 100644 index fd2f11294..000000000 --- a/toolsrc/src/commands_integrate.cpp +++ /dev/null @@ -1,342 +0,0 @@ -#include "pch.h" - -#include "vcpkg_Checks.h" -#include "vcpkg_Commands.h" -#include "vcpkg_Files.h" -#include "vcpkg_System.h" -#include "vcpkg_Util.h" - -namespace vcpkg::Commands::Integrate -{ - static const std::array OLD_SYSTEM_TARGET_FILES = { - System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets", - System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"}; - static const fs::path SYSTEM_WIDE_TARGETS_FILE = - System::get_program_files_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props"; - - static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept - { - return Strings::format(R"###( - - - -)###", - target_path, - target_path); - } - - static std::string create_system_targets_shortcut() noexcept - { - return R"###( - - - - $(LOCALAPPDATA)\vcpkg\vcpkg.user - - - -)###"; - } - - static std::string create_nuget_targets_file_contents(const fs::path& msbuild_vcpkg_targets_file) noexcept - { - const std::string as_string = msbuild_vcpkg_targets_file.string(); - - return Strings::format(R"###( - - - - - - -)###", - as_string, - as_string); - } - - static std::string create_nuget_props_file_contents() noexcept - { - return R"###( - - - true - - -)###"; - } - - static std::string get_nuget_id(const fs::path& vcpkg_root_dir) - { - std::string dir_id = vcpkg_root_dir.generic_string(); - std::replace(dir_id.begin(), dir_id.end(), '/', '.'); - dir_id.erase(1, 1); // Erasing the ":" - - // NuGet id cannot have invalid characters. We will only use alphanumeric and dot. - Util::erase_remove_if(dir_id, [](char c) { return !isalnum(c) && (c != '.'); }); - - const std::string nuget_id = "vcpkg." + dir_id; - return nuget_id; - } - - static std::string create_nuspec_file_contents(const fs::path& vcpkg_root_dir, - const std::string& nuget_id, - const std::string& nupkg_version) - { - static constexpr auto CONTENT_TEMPLATE = R"( - - - @NUGET_ID@ - @VERSION@ - vcpkg - - This package imports all libraries currently installed in @VCPKG_DIR@. This package does not contain any libraries and instead refers to the folder directly (like a symlink). - - - - - - - -)"; - - std::string content = std::regex_replace(CONTENT_TEMPLATE, std::regex("@NUGET_ID@"), nuget_id); - content = std::regex_replace(content, std::regex("@VCPKG_DIR@"), vcpkg_root_dir.string()); - content = std::regex_replace(content, std::regex("@VERSION@"), nupkg_version); - return content; - } - - enum class ElevationPromptChoice - { - YES, - NO - }; - - static ElevationPromptChoice elevated_cmd_execute(const std::string& param) - { - SHELLEXECUTEINFOW sh_ex_info = {0}; - 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; - } - - static fs::path get_appdata_targets_path() - { - static const fs::path LOCAL_APP_DATA = - fs::path(System::get_environment_variable(L"LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO)); - return LOCAL_APP_DATA / "vcpkg" / "vcpkg.user.targets"; - } - - static void integrate_install(const VcpkgPaths& paths) - { - auto& fs = paths.get_filesystem(); - - // 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)) - { - const std::string param = - Strings::format(R"(/c DEL "%s" /Q > nul)", old_system_wide_targets_file.string()); - const ElevationPromptChoice user_choice = elevated_cmd_execute(param); - switch (user_choice) - { - case ElevationPromptChoice::YES: break; - case ElevationPromptChoice::NO: - System::println(System::Color::warning, "Warning: Previous integration file was not removed"); - Checks::exit_fail(VCPKG_LINE_INFO); - default: Checks::unreachable(VCPKG_LINE_INFO); - } - } - } - - std::error_code ec; - const fs::path tmp_dir = paths.buildsystems / "tmp"; - fs.create_directory(paths.buildsystems, ec); - fs.create_directory(tmp_dir, ec); - - bool should_install_system = true; - const Expected system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE); - static const std::regex RE(R"###()###"); - if (const auto contents_data = system_wide_file_contents.get()) - { - std::match_results match; - const auto found = std::regex_search(*contents_data, match, RE); - if (found) - { - const int ver = atoi(match[1].str().c_str()); - if (ver >= 1) should_install_system = false; - } - } - - if (should_install_system) - { - const fs::path sys_src_path = tmp_dir / "vcpkg.system.targets"; - fs.write_contents(sys_src_path, create_system_targets_shortcut()); - - const std::string param = Strings::format(R"(/c mkdir "%s" & copy "%s" "%s" /Y > nul)", - SYSTEM_WIDE_TARGETS_FILE.parent_path().string(), - sys_src_path.string(), - SYSTEM_WIDE_TARGETS_FILE.string()); - const ElevationPromptChoice user_choice = elevated_cmd_execute(param); - switch (user_choice) - { - case ElevationPromptChoice::YES: break; - case ElevationPromptChoice::NO: - System::println(System::Color::warning, "Warning: integration was not applied"); - Checks::exit_fail(VCPKG_LINE_INFO); - default: Checks::unreachable(VCPKG_LINE_INFO); - } - - Checks::check_exit(VCPKG_LINE_INFO, - fs.exists(SYSTEM_WIDE_TARGETS_FILE), - "Error: failed to copy targets file to %s", - SYSTEM_WIDE_TARGETS_FILE.string()); - } - - const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; - fs.write_contents(appdata_src_path, - create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.string())); - auto appdata_dst_path = get_appdata_targets_path(); - - const auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec); - - if (!rc || ec) - { - System::println(System::Color::error, - "Error: Failed to copy file: %s -> %s", - appdata_src_path.string(), - appdata_dst_path.string()); - Checks::exit_fail(VCPKG_LINE_INFO); - } - System::println(System::Color::success, "Applied user-wide integration for this vcpkg root."); - const fs::path cmake_toolchain = paths.buildsystems / "vcpkg.cmake"; - System::println("\n" - "All MSBuild C++ projects can now #include any installed libraries.\n" - "Linking will be handled automatically.\n" - "Installing new libraries will make them instantly available.\n" - "\n" - "CMake projects should use -DCMAKE_TOOLCHAIN_FILE=%s", - cmake_toolchain.generic_string()); - - Checks::exit_success(VCPKG_LINE_INFO); - } - - static void integrate_remove(Files::Filesystem& fs) - { - const fs::path path = get_appdata_targets_path(); - - std::error_code ec; - const bool was_deleted = fs.remove(path, ec); - - Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %d", ec.message()); - - if (was_deleted) - { - System::println(System::Color::success, "User-wide integration was removed"); - } - else - { - System::println(System::Color::success, "User-wide integration is not installed"); - } - - Checks::exit_success(VCPKG_LINE_INFO); - } - - static void integrate_project(const VcpkgPaths& paths) - { - auto& fs = paths.get_filesystem(); - - const fs::path& nuget_exe = paths.get_nuget_exe(); - - const fs::path& buildsystems_dir = paths.buildsystems; - const fs::path tmp_dir = buildsystems_dir / "tmp"; - std::error_code ec; - fs.create_directory(buildsystems_dir, ec); - fs.create_directory(tmp_dir, ec); - - const fs::path targets_file_path = tmp_dir / "vcpkg.nuget.targets"; - const fs::path props_file_path = tmp_dir / "vcpkg.nuget.props"; - const fs::path nuspec_file_path = tmp_dir / "vcpkg.nuget.nuspec"; - const std::string nuget_id = get_nuget_id(paths.root); - const std::string nupkg_version = "1.0.0"; - - fs.write_contents(targets_file_path, create_nuget_targets_file_contents(paths.buildsystems_msbuild_targets)); - fs.write_contents(props_file_path, create_nuget_props_file_contents()); - fs.write_contents(nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version)); - - // Using all forward slashes for the command line - const std::wstring cmd_line = Strings::wformat(LR"("%s" pack -OutputDirectory "%s" "%s" > nul)", - nuget_exe.native(), - buildsystems_dir.native(), - nuspec_file_path.native()); - - const int exit_code = System::cmd_execute_clean(cmd_line); - - const fs::path nuget_package = buildsystems_dir / Strings::format("%s.%s.nupkg", nuget_id, nupkg_version); - Checks::check_exit( - VCPKG_LINE_INFO, exit_code == 0 && fs.exists(nuget_package), "Error: NuGet package creation failed"); - System::println(System::Color::success, "Created nupkg: %s", nuget_package.string()); - - auto source_path = buildsystems_dir.u8string(); - source_path = std::regex_replace(source_path, std::regex("`"), "``"); - - System::println(R"( -With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste: - Install-Package %s -Source "%s" -)", - nuget_id, - source_path); - - Checks::exit_success(VCPKG_LINE_INFO); - } - - const char* const INTEGRATE_COMMAND_HELPSTRING = - " vcpkg integrate install Make installed packages available user-wide. Requires admin privileges on " - "first use\n" - " vcpkg integrate remove Remove user-wide integration\n" - " vcpkg integrate project Generate a referencing nuget package for individual VS project use\n"; - - void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) - { - static const std::string EXAMPLE = Strings::format("Commands:\n" - "%s", - INTEGRATE_COMMAND_HELPSTRING); - args.check_exact_arg_count(1, EXAMPLE); - args.check_and_get_optional_command_arguments({}); - - if (args.command_arguments[0] == "install") - { - return integrate_install(paths); - } - if (args.command_arguments[0] == "remove") - { - return integrate_remove(paths.get_filesystem()); - } - if (args.command_arguments[0] == "project") - { - return integrate_project(paths); - } - - Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown parameter %s for integrate", args.command_arguments[0]); - } -} -- cgit v1.2.3