Perhaps not recommended way but if you have VisualStudio on the build agent you can utilize that to build the installer using the VisualStudio Command Line Switches.
To build installer it's important that you build app first, then the installer or you most likely will run into runtime errors.
There's no built in alias in Cake for the VisualStudio command line (devenv.com
), but you could just launch the process or as in my example below hijack the MSBuild
alias.
Example project
The example project will have an application called "TheApp" and an installer called "TheInstaller" like this:

build.cake
I've created a minimal cake script just demonstrate how to first build project with MSBuild and then installer with VisualStudio. Normally you'll have tasks for clean/nuget restore etc.
FilePath vsToolPath = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/devenv.com";
FilePath solutionPath = "./InstallerTest.sln";
FilePath appProjectPath = " ./TheApp/TheApp.csproj";
string configuration = "Release";
Task("Build")
.Does(() =>
{
// Build project
MSBuild(appProjectPath, new MSBuildSettings {
Verbosity = Verbosity.Minimal,
Configuration = configuration
});
// Build installer
MSBuild(solutionPath, new MSBuildSettings {
ToolPath = vsToolPath,
ArgumentCustomization = args=>new ProcessArgumentBuilder()
.AppendQuoted(solutionPath.FullPath)
.Append("/build")
.Append(configuration)
.Append("/project")
.Append("TheInstaller")
});
});
RunTarget("Build");
- vsToolPath is that to devenv.com (located along devenv.exe)
- solutionPath is the path to solution file
- appProjectPath is the path to application csproj/project file
- configuration is the configuration to build i.e. Release / Debug.
example output
If all goes well you should see a build log similar to below
C:\InstallerTest> cake .\build.cake
========================================
Build
========================================
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
TheApp -> C:\InstallerTest\TheApp\bin\Release\TheApp.exe
Microsoft Visual Studio 2015 Version 14.0.25420.1.
Copyright (C) Microsoft Corp. All rights reserved.
------ Starting pre-build validation for project 'TheInstaller' ------
------ Pre-build validation for project 'TheInstaller' completed ------
1>------ Build started: Project: TheInstaller, Configuration: Release ------
Building file 'C:\InstallerTest\TheInstaller\Release\TheInstaller.msi'...
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
Task Duration
--------------------------------------------------
Build 00:00:06.2353275
--------------------------------------------------
Total: 00:00:06.2353275