MSBuild (Visual Studio)
If you are using CMake to generate your Visual Studio projects, this is not the right section, go to CMake instead. This section is about native integration with Microsoft MSBuild, using properties files.
Conan can be integrated with MSBuild natively, the build system of Visual Studio in different ways:
MSBuildhelpers to generate properties files for your project, containing information about the project dependencies and toolchain. This is the new integration that is experimental but will become the standard one in Conan 2.0. Go to conan.tools.microsoft for more information.
visual_studio_multigenerators to create a MSBuild properties conanbuildinfo.props file. This is the older integration, it is more stable now, but it wil be deprecated and removed in Conan 2.0. Keep reading this page for more information.
With visual_studio generator
Use the visual_studio generator, or visual_studio_multi, if you are maintaining your Visual Studio projects, and want to use Conan to to tell Visual Studio how to find your third-party dependencies.
You can use the visual_studio generator to manage your requirements via your Visual Studio project.
This generator creates a Visual Studio project properties file, with all the include paths, lib paths, libs, flags etc., that can be imported in your project.
conanfile.txt and change (or add) the
Install the requirements:
$ conan install .
Go to your Visual Studio project, and open the Property Manager (usually in View -> Other Windows -> Property Manager).
Click the + icon and select the generated
Build your project as usual.
Remember to set your project’s architecture and build type accordingly, explicitly or implicitly, when issuing the conan install command. If these values don’t match, your build will probably fail.
Check visual_studio for the complete reference.
Build an existing Visual Studio project
You can build an existing Visual Studio from your
build() method using the MSBuild() build helper.
from conans import ConanFile, MSBuild
msbuild = MSBuild(self)
You can use the sub-setting
toolset of the Visual Studio compiler to specify a custom toolset.
It will be automatically applied when using the
MSBuild() build helpers.
The toolset can also be specified manually in these build helpers with the
By default, Conan will not generate a new binary package if the specified
matches an already generated package for the corresponding
Check the package_id() reference to learn more.
Check the CMake() reference section for more info.