1

The build.cake is like this:

Task("Build")
  .Does(() =>
{
  MSBuild("./xxx.sln", new MSBuildSettings {
    Verbosity = Verbosity.Minimal,
    ToolVersion = MSBuildToolVersion.VS2015,
    Configuration = "Release",
  });
});

The xxx.sln contains xxx_Setup.vdproj, but it doesn't get built when I run

.\build.ps1 -Target Build
user1633272
  • 2,007
  • 5
  • 25
  • 48
  • If you enable diagnostic verbosity, as described here: http://stackoverflow.com/questions/38658660/how-to-enable-diagnostic-verbosity-for-cake What is the actual msbuild command that is executed? How does that differ from an msbuild command that does build that project? – Gary Ewan Park Sep 18 '16 at 15:26
  • The log shows other projects in this solution get built except installer project. Seems that MSBuild can't build vdproj. – user1633272 Sep 18 '16 at 16:02
  • Is the tooling installed on the computer for building vdproj files? – Patrik Svensson Sep 18 '16 at 16:14
  • You will need to have Visual Studio installed on the computer and have this vsix extension installed as well: https://visualstudiogallery.msdn.microsoft.com/f1cc3f3e-c300-40a7-8797-c509fb8933b9 – Patrik Svensson Sep 18 '16 at 16:15
  • Yes, I have installed it, and can build MSI while building solution from IDE – user1633272 Sep 18 '16 at 16:35
  • HOw can I install ***cake*** ? – Kiquenet Feb 27 '17 at 16:29

2 Answers2

1

It would appear, based on this discussion:

http://help.appveyor.com/discussions/problems/626-added-a-visual-studio-install-project-and-now-and-getting-errors-during-build

That MSBuild does not support the building of vdproj files. Instead, this is something that Visual Studio knows how to do, but not MSBuild,

This is further backed up by this blog post:

http://techproblemssolved.blogspot.co.uk/2009/05/msbuild-and-vdproj-files.html

The suggested workaround in both cases is either:

  • Move to another packaging technology, such as WiX.
  • Invoke Visual Studio directly (i.e. devenv.exe) to build the project

It is up to you how you proceed, however, personally, I don't like the second option.

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
1

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:

example project root

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
devlead
  • 4,935
  • 15
  • 36