Building from the Command Line

Additionally to Visual Studio, the SDK can also be built and packaged from the command line. This is mostly useful for automation, and packaging custom builds.

The preferred (most flexible) way to build from the command line is to use the stormancer.build.proj MSBuild project, located at the root of the C++ SDK source tree.

This project accepts several properties that you can set as arguments to an MSBuild invocation:

  • BuildSpecs

    The list of projects to build, as a Json array. It must have the following format:

    [
            {
                    "solutionName": {
                            "property1": "value",
                            "property2": "value2",
                            ...
                    }
            },
            {
                    "solution2name": { ... }
            },
            ...
    ]
    

    By default, this is set to:

    [
            {
                    "stormancer-sdk-cpp-141.sln": {
                            "Platform": "x64",
                            "Configuration": "Debug"
                    }
            },
            {
                    "stormancer-sdk-cpp-141.sln": {
                            "Platform": "x64",
                            "Configuration": "Release"
                    }
            }
    ]
    

    Which means building the library for 64-bit Windows in both Release and Debug mode.

    Note: you can use the special token {workingDir} in any of the keys or values of the Json object. It will be expanded to the working directory of the build. See Examples for a typical use case.

  • PackageName

    When building a package (Package target), this can be set to a string that will be part of the final package name. For instance, you might want to set it to the name of the platform that you build for.

It also defines 3 targets:

  • Build

    Build the projects specified in BuildSpecs.

  • Rebuild

    Perform a full rebuild of the projects specified in BuildSpecs.

  • Package

    Build the projects specified in BuildSpecs, and package them together in a zip archive. The archive will be named according to this scheme:

    StormancerSdkCpp-<git version as returned by 'git describe'>.zip
    

    Or, if you specified PackageName in the command line:

    StormancerSdkCpp-<PackageName>-<git version as returned by 'git describe'>.zip
    

Examples

The following example MSBuild invocations are run from a Visual Studio Developer Command Prompt, where the current directory is the root of the Stormancer C++ SDK.

Build the library for 64-bit Windows in Release mode:

msbuild.exe stormancer.build.proj -t:Build '/p:BuildSpecs="[{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Release\",\"Platform\": \"x64\"}}]"'

Note the particular quoting around the BuildSpecs property argument. It is required to prevent MSBuild or the command prompt from interpreting characters such as , or ; that we might want to pass as properties.

Make a zip package containing the Windows and Linux release and debug builds:

msbuild.exe stormancer.build.proj -t:Package '/p:BuildSpecs="[{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Release\",\"Platform\":\"x64\"}},{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Release\",\"Platform\":\"Linux-x64\"}},{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Debug\",\"Platform\":\"x64\"}},{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Debug\",\"Platform\":\"Linux-x64\"}}]"'

Make a Linux build tailored for Unreal Engine 4.22:

msbuild.exe stormancer.build.proj -t:Build '/p:BuildSpecs="[{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Release\",\"Platform\":\"Linux-x64\",\"LinuxProps\":\"{workingDir}\\platforms\linux\UnrealEngine4.22\LinuxUE422.props\"}}]"'

Package 64-bit Windows Debug/Release builds, and name the package ‘Win64’:

msbuild.exe stormancer.build.proj -t:Package /p:PackageName=Win64 '/p:BuildSpecs="[{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Release\",\"Platform\": \"x64\"}},{\"stormancer-sdk-cpp-141.sln\":{\"Configuration\":\"Debug\",\"Platform\": \"x64\"}}]"'