diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-20 13:10:14 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-21 18:06:52 -0700 |
| commit | 8606a8b1270fa0d2295d69656ee41520531e8966 (patch) | |
| tree | ae6e5d5c521aee67140169397a7adf72718609d9 /toolsrc/src/commands_export.cpp | |
| parent | e2dc4eb0ad0e9c097cc856c9cd4eea95a0d994cd (diff) | |
| download | vcpkg-8606a8b1270fa0d2295d69656ee41520531e8966.tar.gz vcpkg-8606a8b1270fa0d2295d69656ee41520531e8966.zip | |
`export`: add nuget export
Diffstat (limited to 'toolsrc/src/commands_export.cpp')
| -rw-r--r-- | toolsrc/src/commands_export.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
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 <regex> 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"( +<package> + <metadata> + <id>@NUGET_ID@</id> + <version>@VERSION@</version> + <authors>cpp-packages</authors> + <description> + Placeholder description + </description> + </metadata> + <files> + <file src="exported\**" target="" /> + <file src="exported\.vcpkg-root" target="" /> + <file src="scripts\buildsystems\msbuild\applocal.ps1" target="build\native\applocal.ps1" /> + <file src="scripts\buildsystems\msbuild\vcpkg.targets" target="build\native\@NUGET_ID@.targets" /> + <file src="scripts\buildsystems\vcpkg.cmake" target="build\native\vcpkg.cmake" /> + </files> +</package> +)"; + + 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); } } |
