Vcpkg: introducing export command

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, x86 or UWP.

Today we are delighted to announce a new command: vcpkg export. 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.

The syntax for the new command is:

vcpkg export <pkg1> <pkg2> ... --[options]

You have several options for the export format:

  • –zip
  • –7zip
  • –nuget
  • –raw (uncompressed folder)

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 – no additional dependencies are required.

Here are some examples that demonstrate ways you can use vcpkg export.

i. Exporting to nuget
> vcpkg export cpprestsdk zlib --nuget
The following packages are already built and will be exported:
* boost:x86-windows
* bzip2:x86-windows
cpprestsdk:x86-windows
* openssl:x86-windows
* websocketpp:x86-windows
zlib:x86-windows
Additional packages (*) need to be exported to complete this operation.
Exporting package zlib:x86-windows...
Exporting package zlib:x86-windows... done
Exporting package openssl:x86-windows...
Exporting package openssl:x86-windows... done
Exporting package bzip2:x86-windows...
Exporting package bzip2:x86-windows... done
Exporting package boost:x86-windows...
Exporting package boost:x86-windows... done
Exporting package websocketpp:x86-windows...
Exporting package websocketpp:x86-windows... done
Exporting package cpprestsdk:x86-windows...
Exporting package cpprestsdk:x86-windows... done
Creating nuget package...
Creating nuget package... done
NuGet package exported at: E:/workspace/vcpkg/vcpkg-export-20170502-150917.nupkg

With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:

Install-Package vcpkg-export-20170502-150917 -Source "E:\workspace\vcpkg"
ii. Exporting to 7zip and zip

You can specify more than one of these options to export in multiple formats.

> vcpkg export zlib --7zip --zip
The following packages are already built and will be exported:
zlib:x86-windows
Exporting package zlib:x86-windows...
Exporting package zlib:x86-windows... done
Creating zip archive...
Creating zip archive... done
Zip archive exported at: E:/workspace/vcpkg /vcpkg-export-20170502-161923.zip

To use the exported libraries in CMake projects use:

"-DCMAKE_TOOLCHAIN_FILE=[...]/scripts/buildsystems/vcpkg.cmake"

Creating 7zip archive...
Creating 7zip archive... done
7zip archive exported at: E:/workspace/vcpkg/vcpkg-export-20170502-161923.7z

To use the exported libraries in CMake projects use:

"-DCMAKE_TOOLCHAIN_FILE=[...]/scripts/buildsystems/vcpkg.cmake"
iii. Exporting multiple libraries for multiple architectures

You can export multiple libraries as well as multiple architectures of the same library in the same export file.

> vcpkg export gtest zlib gtest:x64-windows zlib:x64-windows --nuget
The following packages are already built and will be exported:
gtest:x86-windows
gtest:x64-windows
zlib:x86-windows
zlib:x64-windows
Exporting package zlib:x86-windows...
Exporting package zlib:x86-windows... done
Exporting package zlib:x64-windows...
Exporting package zlib:x64-windows... done
Exporting package gtest:x86-windows...
Exporting package gtest:x86-windows... done
Exporting package gtest:x64-windows...
Exporting package gtest:x64-windows... done
Creating nuget package...
Creating nuget package... done
NuGet package exported at: E:/workspace/vcpkg/vcpkg-export-20170502-150917.nupkg

With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:

Install-Package vcpkg-export-20170502-150917 -Source "E:\workspace\vcpkg"

Using the exported binaries

i. Visual Studio Project

To consume the binaries you created using vcpkg export command into a Visual Studio project is to use the vcpkg export –nuget option, and then add the .nupkg to your project as every other NuGet package. Other export options (–zip, –7zip, –raw) contain the necessary .targets file, for msbuild integration in more advanced scenarios, inside scripts\buildsystems\msbuild\.

ii. CMake

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:

> cmake .. "-DCMAKE_TOOLCHAIN_FILE=E:/workspace/vcpkg/vcpkg-export-20170502-161923/scripts/buildsystems/vcpkg.cmake"

Tell us what you think

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 GitHub or contributing to the code itself!

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>