{"id":15585,"date":"2017-05-03T10:18:06","date_gmt":"2017-05-03T18:18:06","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=15585"},"modified":"2019-02-18T17:48:31","modified_gmt":"2019-02-18T17:48:31","slug":"vcpkg-introducing-export-command","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-introducing-export-command\/","title":{"rendered":"Vcpkg: introducing export command"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/Microsoft\/vcpkg\/\">Vcpkg<\/a> helps you acquire and <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows\/\">build open source libraries on Windows<\/a>. Since September 2016, the community added more than 200 libraries in the vcpkg catalog and has been contributing actively to the code itself. Vcpkg now supports Visual Studio 2015 and Visual Studio 2017 and can target dynamic or static libraries and platforms like x64, x86 or UWP.<\/p>\n<p>Today we are delighted to announce a new command: <b>vcpkg export<\/b>. As you told us in our recent survey, there is a need for a command that exports the binaries that you built using vcpkg. The purpose of this new command is to let you share and redistribute the binaries generated using vcpkg with other developers who want to use it in their project. For example, the team responsible for 3rd party library acquisition in an enterprise can use vcpkg to generate a common set of library binaries used by enterprise projects, and then use vcpkg export to share those binaries (including the .h, the .lib and all thing needed to build against these libraries) with internal developers.<\/p>\n<p>The syntax for the new command is:<\/p>\n<pre class=\"code\">vcpkg export &lt;pkg1&gt; &lt;pkg2&gt; ... --[options]<\/pre>\n<p>You have several options for the export format:<\/p>\n<ul>\n<li>&#8211;zip<\/li>\n<li>&#8211;7zip<\/li>\n<li>&#8211;nuget<\/li>\n<li>&#8211;raw (uncompressed folder)<\/li>\n<\/ul>\n<p>When you specify a package to export, all its dependencies are also included in the exported archive. This means the exported packages can stand on their own &#8211; no additional dependencies are required.<\/p>\n<p>Here are some examples that demonstrate ways you can use vcpkg export.<\/p>\n<h6>i. Exporting to nuget<\/h6>\n<pre class=\"code\">&gt; vcpkg export cpprestsdk zlib --nuget\nThe following packages are already built and will be exported:\n* boost:x86-windows\n* bzip2:x86-windows\ncpprestsdk:x86-windows\n* openssl:x86-windows\n* websocketpp:x86-windows\nzlib:x86-windows\nAdditional packages (*) need to be exported to complete this operation.\nExporting package zlib:x86-windows...\nExporting package zlib:x86-windows... done\nExporting package openssl:x86-windows...\nExporting package openssl:x86-windows... done\nExporting package bzip2:x86-windows...\nExporting package bzip2:x86-windows... done\nExporting package boost:x86-windows...\nExporting package boost:x86-windows... done\nExporting package websocketpp:x86-windows...\nExporting package websocketpp:x86-windows... done\nExporting package cpprestsdk:x86-windows...\nExporting package cpprestsdk:x86-windows... done\nCreating nuget package...\nCreating nuget package... done\nNuGet package exported at: E:\/workspace\/vcpkg\/vcpkg-export-20170502-150917.nupkg\n\nWith a project open, go to Tools-&gt;NuGet Package Manager-&gt;Package Manager Console and paste:\n\nInstall-Package vcpkg-export-20170502-150917 -Source \"E:\\workspace\\vcpkg\"<\/pre>\n<h6>ii. Exporting to 7zip and zip<\/h6>\n<p>You can specify more than one of these options to export in multiple formats.<\/p>\n<pre class=\"code\">&gt; vcpkg export zlib --7zip --zip\nThe following packages are already built and will be exported:\nzlib:x86-windows\nExporting package zlib:x86-windows...\nExporting package zlib:x86-windows... done\nCreating zip archive...\nCreating zip archive... done\nZip archive exported at: E:\/workspace\/vcpkg \/vcpkg-export-20170502-161923.zip\n\nTo use the exported libraries in CMake projects use:\n\n\"-DCMAKE_TOOLCHAIN_FILE=[...]\/scripts\/buildsystems\/vcpkg.cmake\"\n\nCreating 7zip archive...\nCreating 7zip archive... done\n7zip archive exported at: E:\/workspace\/vcpkg\/vcpkg-export-20170502-161923.7z\n\nTo use the exported libraries in CMake projects use:\n\n\"-DCMAKE_TOOLCHAIN_FILE=[...]\/scripts\/buildsystems\/vcpkg.cmake\"<\/pre>\n<h6><a><\/a>iii. Exporting multiple libraries for multiple architectures<\/h6>\n<p>You can export multiple libraries as well as multiple architectures of the same library in the same export file.<\/p>\n<pre class=\"code\">&gt; vcpkg export gtest zlib gtest:x64-windows zlib:x64-windows --nuget\nThe following packages are already built and will be exported:\ngtest:x86-windows\ngtest:x64-windows\nzlib:x86-windows\nzlib:x64-windows\nExporting package zlib:x86-windows...\nExporting package zlib:x86-windows... done\nExporting package zlib:x64-windows...\nExporting package zlib:x64-windows... done\nExporting package gtest:x86-windows...\nExporting package gtest:x86-windows... done\nExporting package gtest:x64-windows...\nExporting package gtest:x64-windows... done\nCreating nuget package...\nCreating nuget package... done\nNuGet package exported at: E:\/workspace\/vcpkg\/vcpkg-export-20170502-150917.nupkg\n\nWith a project open, go to Tools-&gt;NuGet Package Manager-&gt;Package Manager Console and paste:\n\nInstall-Package vcpkg-export-20170502-150917 -Source \"E:\\workspace\\vcpkg\"<\/pre>\n<h4><a><\/a><a><\/a>Using the exported binaries<\/h4>\n<h6><a><\/a>i. Visual Studio Project<\/h6>\n<p>To consume the binaries you created using vcpkg export command into a Visual Studio project is to use the vcpkg export &#8211;nuget option, and then add the .nupkg to your project as every other NuGet package. Other export options (&#8211;zip, &#8211;7zip, &#8211;raw) contain the necessary .targets file, for msbuild integration in more advanced scenarios, inside scripts\\buildsystems\\msbuild\\.<\/p>\n<h6><a><\/a>ii. CMake<\/h6>\n<p>A CMake toolchain file is included when exporting from vcpkg export. It is in scripts\\buildsystems\\. To use it, you need to specify the CMAKE_TOOLCHAIN_FILE variable when calling CMake:<\/p>\n<pre class=\"code\">&gt; cmake .. \"-DCMAKE_TOOLCHAIN_FILE=E:\/workspace\/vcpkg\/vcpkg-export-20170502-161923\/scripts\/buildsystems\/vcpkg.cmake\"<\/pre>\n<h4>Tell us what you think<\/h4>\n<p>As always, we really want this project to be your tool. If you need other export formats, just let us know by creating an issue on <a href=\"https:\/\/github.com\/Microsoft\/vcpkg\/\">GitHub<\/a> or contributing to the code itself!<\/p>\n<p>We have also verified that all the libraries in the vcpkg catalog work with VS 2017, so if you encounter issues when upgrading, do let us know! We hope you enjoy using vcpkg to migrate your project to Visual Studio 2017.pre&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vcpkg helps you acquire and build open source libraries on Windows. Since September 2016, the community added more than 200 libraries in the vcpkg catalog and has been contributing actively to the code itself. Vcpkg now supports Visual Studio 2015 and Visual Studio 2017 and can target dynamic or static libraries and platforms like x64, [&hellip;]<\/p>\n","protected":false},"author":316,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[272],"tags":[311,271,312,273],"class_list":["post-15585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vcpkg","tag-binary","tag-cpp","tag-export","tag-vcpkg"],"acf":[],"blog_post_summary":"<p>Vcpkg helps you acquire and build open source libraries on Windows. Since September 2016, the community added more than 200 libraries in the vcpkg catalog and has been contributing actively to the code itself. Vcpkg now supports Visual Studio 2015 and Visual Studio 2017 and can target dynamic or static libraries and platforms like x64, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/15585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/316"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=15585"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/15585\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=15585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=15585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=15585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}