Say you have the following directory structure:

To compile all projects under the src directory you can use the following code:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectFiles Include="C:\YourApplicationFolder\src\**\*.csproj" /> </ItemGroup>
<Target Name="Compile">
<MSBuild Projects="@(ProjectFiles)" />
</Target>
</Project>
This will loop through all the folders and build each project file. Since MSBuild automatically resolves dependencies between projects, it will build everything in the correct order.