Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2014 08:58
What would you like to do?
Source for a minimal C# compiler for use in batch files see
$opt = New-Object System.CodeDom.Compiler.CompilerParameters;
$opt.GenerateInMemory = $true;
$cr = [System.CodeDom.Compiler.CodeDomProvider]::CreateProvider("CSharp").CompileAssemblyFromSource($opt, "public class App { public static void Main() { "+ $input+" } }");
$obj = $cr.CompiledAssembly.CreateInstance("App");
$obj.GetType().GetMethod("Main").Invoke($obj, $null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment