Always Generate Binary Logs
CRITICAL: Mandatory Rule
ALWAYS pass the /bl switch when running any MSBuild-based command. This is a non-negotiable requirement for all .NET builds.
Commands That Require /bl
You MUST add the /bl:N.binlog flag to:
- •
dotnet build - •
dotnet test - •
dotnet pack - •
dotnet publish - •
dotnet restore - •
msbuildormsbuild.exe - •Any other command that invokes MSBuild
Naming Convention
Use an incrementing counter for the binlog filename, continuing from existing binlogs in the directory:
- •Before the first build, check for existing
*.binlogfiles with numeric names (e.g.,1.binlog,5.binlog,12.binlog) - •Find the highest number and start from that number + 1
- •If no numeric binlogs exist, start at 1
bash
# Example: Directory already contains 5.binlog, 6.binlog, 7.binlog # First build in this session starts at 8 dotnet build /bl:8.binlog # Second build dotnet test /bl:9.binlog # Third build dotnet pack /bl:10.binlog
The counter increments across ALL MSBuild invocations, preserving history across sessions.
Why This Matters
- •Unique names prevent overwrites - You can always go back and analyze previous builds
- •Failure analysis - When a build fails, the binlog is already there for immediate analysis
- •Comparison - You can compare builds before and after changes
- •No re-running builds - You never need to re-run a failed build just to generate a binlog
Examples
bash
# ✅ CORRECT - Check existing binlogs first, then use next number # (Assuming 3.binlog is the highest existing) dotnet build /bl:4.binlog dotnet test /bl:5.binlog dotnet build --configuration Release /bl:6.binlog # ❌ WRONG - Missing /bl flag dotnet build dotnet test # ❌ WRONG - No filename (will overwrite previous) dotnet build /bl dotnet build /bl # ❌ WRONG - Starting at 1 when higher numbers exist dotnet build /bl:1.binlog # if 7.binlog already exists
Remember
- •Check for existing
N.binlogfiles before the first build - •Start at the highest existing number + 1 (or 1 if none exist)
- •Increment the counter for EVERY MSBuild invocation
- •The binlog file will be created in the current working directory