views:

169

answers:

2

Looking at this article from MS, I have a question about the SolutionToBuild section.

<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\path\MySolution.sln />
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\scribble.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\HelloWorld\HelloWorld.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

It says that the sequence of the build is determined by the order above. So, for example, MySolution would be built before scribble.

However, is this safe if scribble is dependant on MySolution? For example, MySolution outputs one or more dlls that are used by scribble. If MySolution and scribble are changed simultaneously, will the build wait for MySolution to be completely compiled before moving to the next project?

A: 

How do you manage solution dependency? Aren't you referencing projects instead? I'm also puzzled about the 'simultaneous' changes on some of your solutions. Please clarify the nature of these changes.

So far, the answers to your questions are:

  1. No. They may be compiled one after the other, but does it qualify for dependency?
  2. Yes. If the sequence is mandatory, the builder will 'wait' until each solution is built (either with success or error) before moving to the next.
Humberto
I've updated my question.Can you clarify what you mean by "If the sequence is mandatory"?
pm_2
I meant, if the build is not parallelized and the solutions are built in queue order... then the builder will indeed wait. However, I don't understand how a simultaneous update in both solutions could occur, or which side effects would arise on the build process -- probably none, because what really matters is the time of the update relative to the start time of the build. BTW, can you test this condition?
Humberto
+2  A: 

You can try to use additional metadata for item SolutionToBuild. Some work with recursion and voilà!

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelone.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\leveltwo.sln</DependsOnSolutions>
    </SolutionToBuild>        
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\leveltwo.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\levelthree.sln;$(SolutionRoot)\TestProject1\TestProject1.sln</DependsOnSolutions>
    </SolutionToBuild>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelthree.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

<Target Name="Build">
    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"                 
             Properties="SolutionFullPath=%(SolutionToBuild.Identity)"/>
</Target>

<Target Name="BuildSolution">   
    <CreateItem Condition="'%(SolutionToBuild.Identity)'=='$(SolutionFullPath)'"
        Include="%(SolutionToBuild.DependsOnSolutions)">
        <Output TaskParameter="Include"
                ItemName="DependentSolutions" />
    </CreateItem>

    <Message Text="Building solution $(SolutionFullPath)..." />        
    <Message Text="Solution $(SolutionFullPath) depends on %(DependentSolutions.Identity)..." 
             Condition="'@(DependentSolutions)'!=''"/>
    <Message Text="Building dependent solutions..."
             Condition="'@(DependentSolutions)'!=''"/>

    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"
             Properties="SolutionFullPath=%(DependentSolutions.Identity)"
             Condition="'@(DependentSolutions)'!=''"/>

    <!-- <MSBuild Projects="$(SolutionFullPath)" /> -->
    <Message Text="Building solution $(SolutionFullPath)... OK" />
</Target>
</Project>
Sergio Rykov