From 8606a8b1270fa0d2295d69656ee41520531e8966 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 20 Apr 2017 13:10:14 -0700 Subject: `export`: add nuget export --- toolsrc/src/commands_export.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'toolsrc/src') diff --git a/toolsrc/src/commands_export.cpp b/toolsrc/src/commands_export.cpp index 85b66a8ff..e336d2d15 100644 --- a/toolsrc/src/commands_export.cpp +++ b/toolsrc/src/commands_export.cpp @@ -6,6 +6,7 @@ #include "vcpkg_Input.h" #include "vcpkg_Util.h" #include "Paragraphs.h" +#include namespace vcpkg::Commands::Export { @@ -135,6 +136,49 @@ namespace vcpkg::Commands::Export System::println(System::Color::success, R"(Files exported at: "%s")", output.generic_string()); + const std::string nuspec_file_content_template = R"( + + + @NUGET_ID@ + @VERSION@ + cpp-packages + + Placeholder description + + + + + + + + + + +)"; + + const std::string nuget_id = "placeholder_id"; + const std::string nupkg_version = "1.0.0"; + const fs::path vcpkg_root_file = (output / ".vcpkg-root"); + + fs.write_contents(vcpkg_root_file, ""); + + std::string nuspec_file_content = std::regex_replace(nuspec_file_content_template, std::regex("@NUGET_ID@"), nuget_id); + //nuspec_file_content = std::regex_replace(nuspec_file_content, std::regex("@VCPKG_DIR@"), vcpkg_root_dir.string()); + nuspec_file_content = std::regex_replace(nuspec_file_content, std::regex("@VERSION@"), nupkg_version); + + const fs::path nuspec_file_path = paths.root / "export.nuspec"; + fs.write_contents(nuspec_file_path, nuspec_file_content); + + const fs::path& nuget_exe = paths.get_nuget_exe(); + + const std::wstring cmd_line = Strings::wformat(LR"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes)", nuget_exe.native(), paths.root.native(), nuspec_file_path.native()); + + + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: NuGet package creation failed"); + + + Checks::exit_success(VCPKG_LINE_INFO); } } -- cgit v1.2.3