6.4.4. MSBuild Integration

To analyze Visual Studio C++ projects (ending in .vcxproj), we provide the command-line tool build_vcxproj. This tool accepts command-line arguments similar to Microsoft’s msbuild.exe and invokes MSBuild for the specified project. The primary effect of using this tool is that it automatically injects the “AxivionBuild” target into the projects.

Additionally, we provide the build_sln tool for building an entire solution (.sln or .slnx file).

Both tools are available only in the Windows installation of the Axivion Suite. For their command-line options, see build_sln and build_vcxproj.

There are two ways to use the MSBuild integration:

  • Using a single project file (.vcxproj).

  • Using a whole solution (.sln or .slnx).

6.4.4.1. Using a single project file

To analyze Visual Studio C++ projects after installation, simply run:

build_vcxproj -p:Configuration=Release MyApplication.vcxproj

To add additional options to the underlying cafeCC driver, 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

To analyze Visual Studio solution (.sln or .slnx) files, use build_sln. Like build_vcxproj, this script calls MSBuild and ensures the “AxivionBuild” target is injected.

Usage:

build_sln -p:Configuration=Release MySolution.sln

build_sln will automatically:

  • Use MSBuildEmitSolution to convert the .sln file 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.

The first two steps apply only to MSBuild versions older than 18. With MSBuild 18 or newer, build_sln invokes the “AxivionBuild” target on the solution directly, without using a .sln.metaproj.

Different Project Configurations

If the referenced projects of the analyzed project do not all use the same platform or configuration option, MSBuild will fail to build a single project because it attempts to apply the same configuration and platform to all referenced projects.

In this case, you must 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 this by calling build_vcxproj with the -solution argument:

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

6.4.4.3. MSBuild Properties

The “AxivionBuild” target evaluates the following MSBuild properties, which can be set using -p:name=value:

WithIRSuffix

If false (default), the projects are built with cafeCC only, and the IR is written to the regular output files (.obj, .lib, .dll, .exe). If true, the projects are also built natively, and the IR is written to files with an additional .ir suffix (.obj.ir, .lib.ir, .dll.ir, .exe.ir). C++/CLI libraries require true.

OmitNativeBuild

If true, the native build is skipped even if WithIRSuffix is true. The value false requires WithIRSuffix=true. C++/CLI libraries cannot be built with true.

AdditionalOptionsCafeCC

Additional options for cafeCC, passed after those from AdditionalOptions.

The MSBuildIntegration build step of axivion_ci sets WithIRSuffix and OmitNativeBuild using its options with_ir_suffix and omit_native_build, which both default to true unless the properties are set explicitly.