Merging Build.Directory.props

April 04, 2018 msbuild, .net

MSBuild version 15 introduced the concept of "Directory.Build.props" files. From the docs:

  • Directory.Build.props is a user-defined file that provides customizations to projects under a directory. This file is automatically imported from Microsoft.Common.props unless the property ImportDirectoryBuildTargets is set to false.

What is not stated here is that only one Directory.Build.props will be imported automatically. Imagine your project exists in the directory C:\repo\src\foo\foo.csproj and there exists a file in both C:\repo\src\Directory.Build.props and C:\repo\Directory.Build.props then only C:\repo\src\Directory.Build.props will be automatically included when building C:\repo\src\foo\foo.csproj. If you would like C:\repo\Directory.Build.props to be included as well, then C:\repo\src\Directory.Build.props will have to include C:\repo\Directory.Build.props like so:

<Project>
    <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>

This is documented here.

Git Quick Push

March 29, 2018 git, batch

Here's a quick one liner to quickly stage all your changes in the current git repo, commit them and then push the commit to origin master branch.

Read More

Poor Man's Template Engine in C# Part 3

Include

March 22, 2018 c#, template, template-engine

In our last episode we implemeted the first two helper funcitons HtmlEncode and If. Today we want to implement Include.

Read More

Poor Man's Template Engine in C# Part 2

HtmlEncode and If

March 14, 2018 c#, template, template-engine

In our last episode we laid the groundwork for our simple template engine. In this episode we'll introduce our first 2 helper functions.

Read More

Poor Man's Template Engine in C# Part 1

Groundwork

March 06, 2018 c#, template, template-engine

If you're looking for a poor man's solution to a templating engine for .net and don't really need the overhead a complete template engine brings with it, I've come up with the following solution.

Read More