Chapter 3. How to build with .NET Core

 

This chapter covers

  • Frameworks, runtimes, and platforms
  • MSBuild fundamentals

Throughout my time as a software developer, there has been a dichotomy between the things I want to do, like write code, and the things I have to do, like build code. I didn’t want to learn makefiles or MSBuild. IDEs also made it possible to skip most of that.

At least until the day when I had to do one specific thing. Then I had to either go through the steep learning curve to figure out what I needed, or copy-paste from Stack Overflow and hope for the best. Neither situation is ideal. Knowing the fundamentals of your build files not only keeps you out of sticky situations, it also lets you know what’s possible. For this chapter, I recommend that you not use an IDE and instead code the exercises by hand.

3.1. Key concepts in .NET Core’s build system

Even experienced .NET Framework developers will find new terminology and concepts in .NET Core. The way projects are built is essentially the same, but there are several improvements.

3.1.1. Introducing MSBuild

In the previous chapter, you created several projects, and the most critical component for building them was the csproj file. A csproj is a C#-specific project file containing MSBuild XML. For F# projects, the project file has an .fsproj extension; VB project files have a .vbproj extension. It’s also possible to import other MSBuild files, but those files don’t usually have the .*proj extensions.

3.2. CSV parser sample project

3.3. Introducing MSBuild

3.4. Dependencies

3.5. Targeting multiple frameworks

Additional resources

Summary

sitemap