Building Visual Studio Solutions from the Command Line

2 minute read

CloudBees Accelerator can build Visual Studio solutions in three different modes:

  • Using Electrify (recommended for VC++)

  • Using ecdevenv as a drop-in replacement for your command-line build

  • Creating a makefile containing the devenv calls and/or MSBuild calls

Using Electrify

If you choose to use Electrify, specify your devenv.exe or msbuild command as follows:

electrify.exe --emake-cm=<cluster_manager_name_or_IP> <emake_options> --electrify-remote=cl.exe;link.exe;lib.exe --electrify-localfile=y --electrifymon --your devenv/msbuild command>

Using ecdevenv

If you choose to use ecdevenv, replace:

devenv.com Solution.sln /build Debug

with:

ecdevenv Solution.sln /build Debug -–emake-cm=<your_cm> /virtualize

ecdevenv does the following:

  1. Converts Solution.sln to NMAKE format.

  2. Calls eMake on the generated files.

The /virtualize flag virtualizes the Visual Studio toolchain, negating the need to install Visual Studio on the agents. You must, however, ensure the relevant versions of .NET and redistributables are installed.

devenv must be in the PATH environment variable before you execute ecdevenv.

Creating a Makefile

Before you can use Accelerator to build your Visual Studio project, make sure you have already installed and run Visual Studio on each agent host for each user (all ECloudInternalUsers ).

Virtualization of the toolchain is not possible when using this method.

If you currently invoke Visual Studio from inside a makefile, you are ready. If you invoke Visual Studio directly from the command line or through a batch file, you must create a makefile for eMake to run. For example:

all:
      devenv /build Release foo.sln

 — or — 

all:
      devenv /build Release foo.sln /project bar.vcproj

The makefile must invoke devenv with the options you currently use. Ensure the correct version of devenv is in your path:

devenv /?

and ensure that the usual Visual Studio environment variables are set.

For Visual Studio 2015 and later, you must add “ /vsp ” to the end of the command line. (When building from ecdevenv.exe, this is added automatically.)

For example:

all:
devenv /build Release foo.sln /vsp

Setting the Path for 64-Bit or Xbox Builds

To run 64-bit or Xbox builds, you must set the path manually.