With Visual Studio 2015 it is possible to have a gulpfile.js with built task. You can also use grunt. I have found a list of further options here.
My question is whether there is a similar option where I could define a build task in C# without the need to create a separate executable that will be called in a pre or post build action? Is there some way I could write a script in C# for build task in a very similar way as I can use gulp?