Self compiling scripts for .NET languages: C#, VB.NET and JScript.NET

Ok, these ones are pretty cool. It took me a few more hours than I thought, but it was worth it.

 

The scripts in the zip file are javascripts which surround another language, and allow you to write .NET applications, but distribute simple text files as scripts.

 

The C# and JScript.net wrappers are perfectly identical, the VB.NET one required a little more playing to get right. – and it’s just the smuggling lines that are different, the script itself is the same.

 

I’ve coded a simple hello world example into each of the languages.

 

The ‘trimmed’ versions allow you to simply add the five lines at the top, and the last line to your source file and have it run anywhere .NET 2.0 is installed.

 

Oh, and even better:  if you drop the .JS on the end, the script loads in Visual Studio just fine as a class—you can do all of your testing with the script header in place and then just rename it when you want to redistribute it.

 

https://serack.org/SelfCompilingScriptExamples.zip

g

Garrett Serack | Program Manager | Connected Identity and Directory| Microsoft Corporationblog: https://blogs.msdn.com/garretts