Originally published on 2015-06-17; fully revised and updated.

Training registration form (original link)
This guide turns a short training announcement into a practical MSBuild reference for DevOps engineers, .NET developers, and release teams. You will learn the core MSBuild model, how to extend builds with custom targets and tasks, and how to troubleshoot build failures and performance issues using repeatable techniques.
Updated MSBuild training curriculum
The original post outlined three core modules. The structure below keeps that intent and adds implementation guidance.
Module 1: MSBuild 4.0 basics
- What MSBuild is and where it fits in the build lifecycle
- Sample project file structure
- Solutions vs. projects
- Targets and tasks
- Properties and items
- Editing project files in Visual Studio
Module 2: Customization and extension
- Build events
- Custom build steps
- Custom build tools
- Custom build targets
- Custom build tasks
- MSBuild extension pack usage patterns
Module 3: Troubleshooting and diagnostics
- Logging and verbosity tuning
- Console logger and file logger usage
- Custom loggers
- Error handling patterns
- Debugging build scripts, tasks, and loggers
- Import conflicts, performance bottlenecks, and incremental build issues
How an MSBuild workflow runs
flowchart TD
A[Developer changes code] --> B[MSBuild loads solution and project files]
B --> C[Evaluate properties and items]
C --> D[Resolve target dependency graph]
D --> E[Execute tasks in target order]
E --> F{Build errors?}
F -- Yes --> G[Inspect logs and fix configuration or code]
G --> A
F -- No --> H[Publish build outputs]
Core MSBuild concepts compared
| Concept | What it represents | Why it matters |
|---|---|---|
| Solution (.sln) | Container of multiple projects | Useful for orchestrating multi-project builds from one entry point |
| Project (.csproj, .vbproj, etc.) | Build definition for a single application or library | Holds references, properties, items, and targets for one unit of build |
| Target | Named phase of work (for example Build, Clean, Publish) | Controls ordering and dependencies across build steps |
| Task | Atomic operation executed inside a target | Performs concrete actions such as compile, copy, create directory, or run tools |
| Property and Item | Configuration values and file collections | Drive conditional logic and input/output behavior |
Practical command-line examples
Use these commands in a terminal or CI job to build, clean, and collect diagnostics.
msbuild MySolution.sln /t:Clean,Build /p:Configuration=Release /m
msbuild MyProject.csproj /t:Build /v:detailed /fl /flp:logfile=msbuild.log;verbosity=diagnostic
msbuild MyProject.csproj /t:Rebuild /p:Configuration=Debug /p:Platform="Any CPU"Code language: JavaScript (javascript)
Customization example: adding a post-build target
This sample shows a simple target that creates an artifacts directory and copies the built output into it.
<Project>
<PropertyGroup>
<ArtifactsDir>$(MSBuildProjectDirectory)\artifacts</ArtifactsDir>
</PropertyGroup>
<Target Name="AfterBuild">
<MakeDir Directories="$(ArtifactsDir)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ArtifactsDir)" />
</Target>
</Project>Code language: HTML, XML (xml)
Troubleshooting options at a glance
| Option | Best for | Typical usage |
|---|---|---|
| Console logger | Immediate feedback in local runs and CI logs | Use /v:minimal, /v:normal, or /v:detailed depending on noise tolerance |
| File logger | Persisting diagnostics for later analysis | Use /fl with /flp:logfile=…;verbosity=diagnostic |
| Custom logger | Special reporting or integration needs | Use /logger:TypeName,AssemblyName when built-in output is insufficient |
| Error handling in targets | Graceful failure behavior | Use explicit target dependencies and clear failure points to avoid silent errors |
Best practices and common pitfalls
- Keep project files readable: group properties, items, and targets logically.
- Prefer explicit target dependencies over hidden side effects in build events.
- Use detailed logging only when troubleshooting; reduce verbosity in normal CI runs.
- Validate incremental build behavior whenever you add custom copy, transform, or generated-file steps.
- Test custom targets in a clean workspace to catch missing assumptions.
- Document non-default properties passed from CI so local and pipeline builds stay consistent.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals