Created
August 31, 2018 10:07
-
-
Save vivami/8b5e117a65ea15f23c2b40a8b15889be to your computer and use it in GitHub Desktop.
Compile C# src at runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile(srcFinal, filename + "_obfuscated.exe"); | |
static void compile(String source, String outfile) { | |
var provider_options = new Dictionary<string, string> | |
{ | |
{"CompilerVersion","v3.5"} | |
}; | |
var provider = new Microsoft.CSharp.CSharpCodeProvider(provider_options); | |
var compiler_params = new System.CodeDom.Compiler.CompilerParameters(); | |
compiler_params.OutputAssembly = outfile; | |
compiler_params.GenerateExecutable = true; | |
// Compile | |
var results = provider.CompileAssemblyFromSource(compiler_params, source); | |
Console.WriteLine("Output file: {0}", outfile); | |
Console.WriteLine("Number of Errors: {0}", results.Errors.Count); | |
foreach (System.CodeDom.Compiler.CompilerError err in results.Errors) { | |
Console.WriteLine("ERROR {0}", err.ErrorText); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment