Lightweight Build Order Logging in MSBuild
If you have a lot of .Net code, projects and solutions to build, it can sometimes be difficult to see the order that the projects are actually being built in without going for the nuclear option of detailed or diagnostics logs in msbuild.
If we use the trick of putting a script into the msbuild ImportAfter folder, we can hook into every build and append each project's build output to a minimal log.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="CaptureBuildOutput" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildOutput>$(SolutionDir)\BuildOrder.txt</BuildOutput>
</PropertyGroup>
<Target Name="BuildOrder" BeforeTargets="BeforeBuild">
<ItemGroup>
<BuildLines Include="$(SolutionFileName): $(ProjectName)" />
</ItemGroup>
<WriteLinesToFile
Lines="@(BuildLines)"
File="$(BuildOutput)"
Encoding="Unicode"
Overwrite="false"
/>
</Target>
</Project>