6.4.4. MSBuild Integration

In order to analyze Visual Studio C++ projects (having the ending .vcxproj), we provide the command-line tool build_vcxproj. This tool accepts command-line arguments similar to Microsoft’s msbuild.exe, and will invoke MSBuild for the specified project. The main effect of using our tool is that it will automatically inject the “AxivionBuild” target into the projects.

In addition, we also provide the build_sln tool for building a whole solution (.sln file).

There are two possible ways of how to use the MSBuild integration:

  • Using a single project file ( .vcxproj.

  • Using a whole solution ( .sln).

6.4.4.1. Using a single project file

In order to analyze Visual Studio C++ projects after successful installation, you can just do:

build_vcxproj -p:Configuration=Release MyApplication.vcxproj

If you have the need to add additional options to the underlying cafeCC driver, you may add /p:AdditionalOptions=... to the msbuild call, e. g.:

build_vcxproj ^
        -p:AdditionalOptions="-w" ^
        -p:Configuration=Release MyApplication.vcxproj

6.4.4.2. Using a whole Solution file

When analyzing Visual Studio solution ( .sln) files, you can use build_sln. Like build_vcxproj, this script will call MSBuild while taking care to inject the “AxivionBuild” target.

Usage:

build_sln -p:Configuration=Release MySolution.sln

build_sln will automatically:

  • use MSBuildEmitSolution to convert the .sln into an MSBuild-format .sln.metaproj.

  • run prepare_metaproj to inject the “AxivionBuild” target into the .sln.metaproj file.

  • set MSBuild properties to inject the “AxivionBuild” target into the individual projects.

Different Project Configurations

If not all referenced projects of the analyzed project use the same platform and/or configuration option, MSBuild will fail to build a single project, as it tries to apply the same configuration and platform to all of its referenced projects.

In this case, you need to provide the solution input to the MSBuild tool in addition to the project input.

Only the specified project (and its dependencies) will be analyzed, but the information from the solution file will be used to apply the correct configurations and platforms.

On the command-line, you can do it by calling build_vcxproj with the -solution argument:

build_vcxproj -p:Configuration=Release -p:Platform="x64" ^
    -solution:MySolution.sln MyProject/MyProject.vcxproj