{"id":47,"date":"2026-10-14T05:41:12","date_gmt":"2026-10-14T05:41:12","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/06\/17\/msbuild-training\/"},"modified":"2026-10-14T05:41:12","modified_gmt":"2026-10-14T05:41:12","slug":"msbuild-training","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/msbuild-training\/","title":{"rendered":"MSBuild Training Guide: Basics, Custom Targets, Logging, and Troubleshooting"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Originally published on 2015-06-17; fully revised and updated.<\/em><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/06\/msbuild-training.png\" alt=\"MSBuild training overview\" width=\"600\" height=\"400\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.google.com\/a\/scmgalaxy.com\/forms\/d\/1kZs21fbihV4AK2a530-9rHbCuCJR-lQj1aAmC3C0aKE\/viewform\" target=\"_blank\" rel=\"noopener\">Training registration form (original link)<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Updated MSBuild training curriculum<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original post outlined three core modules. The structure below keeps that intent and adds implementation guidance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Module 1: MSBuild 4.0 basics<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>What MSBuild is and where it fits in the build lifecycle<\/li><li>Sample project file structure<\/li><li>Solutions vs. projects<\/li><li>Targets and tasks<\/li><li>Properties and items<\/li><li>Editing project files in Visual Studio<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Module 2: Customization and extension<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Build events<\/li><li>Custom build steps<\/li><li>Custom build tools<\/li><li>Custom build targets<\/li><li>Custom build tasks<\/li><li>MSBuild extension pack usage patterns<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Module 3: Troubleshooting and diagnostics<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Logging and verbosity tuning<\/li><li>Console logger and file logger usage<\/li><li>Custom loggers<\/li><li>Error handling patterns<\/li><li>Debugging build scripts, tasks, and loggers<\/li><li>Import conflicts, performance bottlenecks, and incremental build issues<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How an MSBuild workflow runs<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Developer changes code] --> B[MSBuild loads solution and project files]\n    B --> C[Evaluate properties and items]\n    C --> D[Resolve target dependency graph]\n    D --> E[Execute tasks in target order]\n    E --> F{Build errors?}\n    F -- Yes --> G[Inspect logs and fix configuration or code]\n    G --> A\n    F -- No --> H[Publish build outputs]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Core MSBuild concepts compared<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Concept<\/th><th>What it represents<\/th><th>Why it matters<\/th><\/tr><\/thead><tbody><tr><td>Solution (.sln)<\/td><td>Container of multiple projects<\/td><td>Useful for orchestrating multi-project builds from one entry point<\/td><\/tr><tr><td>Project (.csproj, .vbproj, etc.)<\/td><td>Build definition for a single application or library<\/td><td>Holds references, properties, items, and targets for one unit of build<\/td><\/tr><tr><td>Target<\/td><td>Named phase of work (for example Build, Clean, Publish)<\/td><td>Controls ordering and dependencies across build steps<\/td><\/tr><tr><td>Task<\/td><td>Atomic operation executed inside a target<\/td><td>Performs concrete actions such as compile, copy, create directory, or run tools<\/td><\/tr><tr><td>Property and Item<\/td><td>Configuration values and file collections<\/td><td>Drive conditional logic and input\/output behavior<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Practical command-line examples<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use these commands in a terminal or CI job to build, clean, and collect diagnostics.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">msbuild MySolution.sln \/t:Clean,Build \/p:Configuration=Release \/m<\/code><\/span><\/pre>\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">msbuild MyProject.csproj \/t:Build \/v:detailed \/fl \/flp:logfile=msbuild.log;verbosity=diagnostic<\/code><\/span><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">msbuild MyProject.csproj \/t:Rebuild \/p:Configuration=Debug \/p:Platform=<span class=\"hljs-string\">\"Any CPU\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Customization example: adding a post-build target<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This sample shows a simple target that creates an artifacts directory and copies the built output into it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Project<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">PropertyGroup<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ArtifactsDir<\/span>&gt;<\/span>$(MSBuildProjectDirectory)\\artifacts<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ArtifactsDir<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">PropertyGroup<\/span>&gt;<\/span>\n\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Target<\/span> <span class=\"hljs-attr\">Name<\/span>=<span class=\"hljs-string\">\"AfterBuild\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">MakeDir<\/span> <span class=\"hljs-attr\">Directories<\/span>=<span class=\"hljs-string\">\"$(ArtifactsDir)\"<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Copy<\/span> <span class=\"hljs-attr\">SourceFiles<\/span>=<span class=\"hljs-string\">\"$(TargetPath)\"<\/span> <span class=\"hljs-attr\">DestinationFolder<\/span>=<span class=\"hljs-string\">\"$(ArtifactsDir)\"<\/span> \/&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Target<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Project<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting options at a glance<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Option<\/th><th>Best for<\/th><th>Typical usage<\/th><\/tr><\/thead><tbody><tr><td>Console logger<\/td><td>Immediate feedback in local runs and CI logs<\/td><td>Use \/v:minimal, \/v:normal, or \/v:detailed depending on noise tolerance<\/td><\/tr><tr><td>File logger<\/td><td>Persisting diagnostics for later analysis<\/td><td>Use \/fl with \/flp:logfile=&#8230;;verbosity=diagnostic<\/td><\/tr><tr><td>Custom logger<\/td><td>Special reporting or integration needs<\/td><td>Use \/logger:TypeName,AssemblyName when built-in output is insufficient<\/td><\/tr><tr><td>Error handling in targets<\/td><td>Graceful failure behavior<\/td><td>Use explicit target dependencies and clear failure points to avoid silent errors<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Best practices and common pitfalls<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Keep project files readable: group properties, items, and targets logically.<\/li><li>Prefer explicit target dependencies over hidden side effects in build events.<\/li><li>Use detailed logging only when troubleshooting; reduce verbosity in normal CI runs.<\/li><li>Validate incremental build behavior whenever you add custom copy, transform, or generated-file steps.<\/li><li>Test custom targets in a clean workspace to catch missing assumptions.<\/li><li>Document non-default properties passed from CI so local and pipeline builds stay consistent.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A practical, updated MSBuild training reference based on the original course outline. Learn how MSBuild works, how to customize builds, and how to troubleshoot slow or failing pipelines.<\/p>\n","protected":false},"author":1,"featured_media":3461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[8],"tags":[99,1681,884,1684,883,100,97,366,1686,1680,135,1685,1682,94,1683,1673,96],"class_list":["post-47","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-training","tag-bangalore","tag-chennai","tag-classroom","tag-classroom-msbuild-training","tag-course","tag-hyderabad","tag-india","tag-msbuild","tag-msbuild-classroom-training","tag-msbuild-course","tag-msbuild-training","tag-msbuild-training-online","tag-mumbai","tag-online","tag-online-msbuild-training","tag-pune","tag-training"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":79286,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions\/79286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3461"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}