Build script with C#
Asked Answered
O

3

5

For insight into the below, read: http://martinfowler.com/articles/rake.html

I've been using Rake (with Albacore) recently, and like it alot. Mostly the strength of having the Ruby language right at hand when I need it.

I must admit I am alot more at home with C# - and that lead me to thinking if there was an equivalent to Rake in the .NET world.

What I am looking for is a way to write build scripts in C#, or maybe a DSL, having the same dependency programming model, where I can also use C#.

Maybe I'm way off base asking this question. But if it's possible to do with Ruby (and an internal DSL), then I can't right off the bat say why the same wouldn't be possible for C#. And I certainly don't understand why it hasn't already been done :-)

Anyone have some perspectives on the issue?

What we already know:

  • C# needs to be compiled to run, so we would need to create a seperate build-script, that is parsed, and compiled at run-time by an executable.

Thanks in advance!

Solution

Use "Cake" http://cakebuild.net/ -- with Roslyn compiler what I wanted (years ago) is now possible. Thanks Microsoft. And thanks to the people who wrote Cake.

An alternative is to use Powershell. The library is called Psake (saké)

Osteopath answered 16/3, 2012 at 23:36 Comment(5)
Check #2426257Gamic
Because C# isn't a scripting language.Perlis
@AndrewMarshall: It's not too bad as a scripting language either. The only downside is that it (still) requires compilation.Fingerstall
@NiklasB. I suppose what I meant to say was interpreted, and thus requiring compilation to run. Scripting and interpreted (perhaps unfortunately and incorrectly) seem to get combined together a lot, and I'm guilty of doing so myself.Perlis
@Andrew: I realize that. That's why I am talking about a DSL. The point is you would write a build-script, and have an executable that would parse the DSL, and compile and run it at Runtime :-)Osteopath
F
5

Maybe Cake is what you're looking for: https://github.com/cake-build/cake

Fame answered 10/8, 2014 at 0:27 Comment(1)
This is now the correct answer. With the advent of Roslyn, what I was wanting back in '12 is now possible with Cake. I actually wrote a similar project, also called cake, that did the exact same thing, but, The real 'Cake' is far superior to my implementation.Osteopath
T
3

A lot of people do use Rake for build scripts. There are even Rake tasks just for .NET. http://albacorebuild.net/

But there is a c# based make utility I know about. http://shake.codeplex.com/ And I thought I saw one on github. But I think they require a compile and that didn't seem as cool.

I ended up on https://github.com/psake/psake mainly because I wanted to learn Powershell and everyone already had it installed.

Hmm Bounce too https://github.com/refractalize/bounce

Thoracotomy answered 16/3, 2012 at 23:52 Comment(2)
Yeah, I use Albacore already. Sorry, I'll update the question. I think the powershell approach is also very interesting. +1 for that.. I didn't even consider it! It seems the idea has cropped up elsewhere, but is still in it's infantsy.Osteopath
And agreed. I don't want to compile it before I run it. Or atleast, I want to be able to write something like: "cake build.cs", and it would compile and execute the build-script. So of course I am dependant upon a compile somehow.Osteopath
A
0

You can script your build/deployment tasks with msbuild and then script your tasks and execute them from bat files.

Attentive answered 16/7, 2014 at 20:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.