LINQPad (
http://www.linqpad.net/) is a great tool for creating simple
programs without having to launch Visual Studio and cluttering your
workspace with a bunch of console projects. However LINQPad does not
have a way to run these programs outside of the IDE. Enter CS-Script
(
http://www.csscript.net/), which treats C# files like script files.
One issue with LINQPad (.linq) files is that they include a little
header in XML that specifies the type of file and any references or
namespaces needed.
This header prevents CS-Script from processing the file as it is not
valid C#. However, CS-Script has a nice Precompiler feature that will
pre-process the script file before compiling it. This
LinqPadPrecompiler simply removes the header portion and adds the
appropriate references and namespaces. It also wraps the file in a
ScriptClass and prefixes the Main() method with public static. This is
similar to what the built-in AutoclassPrecompiler does.
You can get the code here:
https://gist.github.com/1944790