Using Scriptcs from msbuild

125 views
Skip to first unread message

Mark Heath

unread,
Feb 6, 2014, 9:52:32 AM2/6/14
to scri...@googlegroups.com
I'd like to incorporate some scriptcs tasks to run as part of an msbuild script. I have two questions about how best to do this:

First, I need the scripts to run on everyone's PC, whether or not they have installed scriptcs via chocolatey. So I want to put the scriptcs binaries into a folder and commit it to source control. Do I need everything from my "AppData\Roaming\scriptcs" folder? And is there an "official" way to get scriptcs binaries?

Second, I want scripts to return a non-zero error code so they can fail the build. At the moment, the only way I see of doing this is to throw an exception as the last line of my script. Is there a more elegant way?

thanks
Mark

Janco Wolmarans

unread,
Feb 6, 2014, 10:27:16 AM2/6/14
to Mark Heath, scri...@googlegroups.com
Hi Mark,

Personally, I would recommend that you install scriptcs in the recommended way (using chocholatey) on every machine. It just takes away the pain of managing package dependencies. You could easily create a script that would do that if your goal is to minimise manual work to get the build running on a dev machine.

Secondly, have you looked at Shovel? (https://github.com/jancowol/shovel). I don't think it propagates msbuild errors through at the moment, but it shouldn't be hard to do. I could look into that.

Janco.

Glenn Block

unread,
Feb 6, 2014, 2:21:09 PM2/6/14
to Mark Heath, scri...@googlegroups.com
Hey Mark

This is awesome to hear!

You don't need chocolatey. I recommend you check out our ScriptCs.Hosting nuget package. It will pull in all the bits to allow you host scriptcs in your own application. Then you can just write a custom task for MSBuild, reference the library and essentially go to town.

Check out this deck from Filip: http://www.slideshare.net/FilipW/scriptcs-scripting-hosting-and-extending he also has a great post on extending Glimpse using hosting.

Adam Ralph also has a scriptcs build tool that hosts scriptcs within called Bau.

We'll be happy to help you move this forward!



Mark Heath

unread,
Feb 6, 2014, 2:34:13 PM2/6/14
to scri...@googlegroups.com, Mark Heath
great, I'll check out the scriptcs.hosting package. I have a large number of LinqPad scripts that I have been wanting to incorporate into our build process for some time, and I think scriptcs could be the ideal way to do this. Was hoping to avoid making an msbuild extension and just run from command line, but I have made one before, so shouldn't be too hard.

Mark

Glenn Block

unread,
Feb 6, 2014, 7:40:50 PM2/6/14
to Mark Heath, scri...@googlegroups.com
The main issue is distribution of Roslyn bits. The alternative option is to grab the scriptcs source and build locally. That will then give you a single bin folder which contains scriptcs and all the related dlls.

You can then put that in a folder and run directly from msbuild.

Does that work better?

Vaughn Clement

unread,
Oct 2, 2014, 11:18:29 PM10/2/14
to scri...@googlegroups.com
Did you ever get an answer to your second question?   I tried using return int.  That doesn't work.  Generates a cannot use "return" top-level script code" error message.
Reply all
Reply to author
Forward
0 new messages