vcpkg Environment Activation in Visual Studio
In Visual Studio 2022 17.4 vcpkg environments will now automatically activate. A vcpkg environment is described by a manifest that captures the artifacts necessary for building your application (learn more about vcpkg artifacts). Today the vcpkg artifact experience is focused on embedded developers, but we will be expanding this in time to all C++ development scenarios.
Try vcpkg environment activation
This is part of the Linux and embedded development with C++ workload., so make sure that is selected in your installation.
Today you need to install vcpkg directly, it is not installed with Visual Studio yet. To do so run this command.
iex (iwr -useb "https://aka.ms/vcpkg-init.ps1")
For a project to try with this you can use any of the projects described in our Embedded Development announcement. Originally this required you to activate the vcpkg environment from the command line, then launch VS from that prompt. Now all you need to do is open the project and VS will handle the activation.
To try it clone this repository.
git clone --recursive https://github.com/azure-rtos/getting-started.git
Now open the subfolder getting-started\MXChip\AZ3166 in Visual Studio. You will see the following notification that vcpkg environment activation has started. This may take some time on first use when the artifacts are initially downloaded.
When activation is finished there will be a notification.
If you missed it you can check the notification area by selecting it.
You can also check the current or complete status of the activation in the vcpkg output window.
This sample is a CMake project, so when vcpkg activation is complete CMake cache generation will start and then your project will be ready for use.
Managing the vcpkg environment
Visual Studio integrates the vcpkg environment as part of the Solution explorer.
The opens the vcpkg-configuration.json file which captures the vcpkg environment. Reactivate will activate the vcpkg environment again picking up any changes made to the configuration. removes the vcpkg environment from the current configuration leaving you with a standard Visual Studio environment. If your project depends on compilers or other tools provided by the vcpkg configuration it likely will no longer build and IntelliSense may not work.
Send us your feedback
We hope that these new capabilities will enable you to choose Visual Studio for your C++ development needs and make you more productive. We are very interested in your feedback to continue to improve this experience. The comments below are open, or you can find us on Twitter (@VisualC), or via email at firstname.lastname@example.org.