/msbuildism

MSBuild is complicated. Let's lift the veil on it.

Primary LanguageC#

MSBuildism

Because MSBuild is just as complex as it is powerful, it has quirks that I like to call "msbuildisms." When your incremental build starts to fail for seemingly no reason, or when changing one property suddenly causes your build to fail in four different places. Those are MSBuildisms.

It's important to acknowledge that, because MSBuild is so flexible, there is no single way to accomplish something. Every repo is unique, every build is complicated, and every workaround is just one of many you could have done. Your mileage may vary.

This repo is a collection README's that document what I've learned in my ~4 years on the MSBuild team ❤️. I hope it helps make your MSBuildisms a little easier to solve.

Quick Links

How to Use MSBuild

msbuild works when called within a Developer Command Prompt and uses that Visual Studio's respective copy of MSBuild.exe dotnet msbuild is the .NET SDK's equivalent. It accepts all the same arguments as msbuild.exe.

Set Up MSBuild To Auto-Launch In Windows Terminal

Here's the profile I used for windows terminal:

{
    "commandline": "cmd.exe /k \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Dogfood\\Common7\\Tools\\VsDevCmd.bat",
    "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
    "hidden": false,
    "name": "Dev Command Prompt"
},

NOTE: I found that using cmd.exe /k and a path that contained a space did not play well with VS Code. To work around this, I created a shortcut to a directory that didn't contain a space. For example: C:\\src\VsDevCmd.lnk. Alt + click + drag is an easy way to create a shortcut.