Top-level builds

I'm trying to create a top-level build that spawns the build of several, relatively independent subprojects. Each subproject has its own .SLN file that will be built with the MSBuild task. Ideally, we'd like each sub-project to be in its own target, as well as have an uber-target that includes the targets for all of the subprojects. That way you can either build the entire system or any individual subproject, all from the master build file.

In the past I've done this sort of thing in Nant using the "call" task in the uber-target. I'm not seeing a similar concept in the MSBuild docs. Am I missing something Or is there another way to think about this in the MSBuild world

I thought about using an item group to define the list of sub-projects and passing that to the MSBuild task, but that's not as flexible as having a target for each subproject (which may include more than just an MSBuild task).



Answer this question

Top-level builds

  • Chris Mann - MSFT

    The task you need is the MSBuild task... it can build targets in the current project just as easily as it can in a different project.

    Do something like this to build a target in the current project:
    <MSBuild Projects="$(MSBuildProjectFile)" Targets="mytarget"/>

    (After beta 2, we've created a separate "Call" task, which is just like the MSBuild task but implicitly applies to the current project. You don't have that task yet.)

    We do something similar to what you plan to do when we have to build a solution file. We convert the .sln in-memory into an msbuild project. To see this project, set an environment variable
    set msbuildemitsolution=1
    then build a solution. You'll see something like my.sln.proj emitted in that folder, which you can look at.

    If you need more help post back, preferably with a snippet...



  • Rob Biernat

    Perfect, that's exactly what I needed to know. Thanks. The Call task sounds like a good addition.

  • Top-level builds