Fix strange scripting errors.
This commit is contained in:
parent
035ab6e830
commit
fdbdf0ce62
4 changed files with 15 additions and 3 deletions
|
@ -14,16 +14,26 @@ namespace SnapWrap
|
|||
string output = args[1];
|
||||
var customImports = args[2].Split("..");
|
||||
|
||||
if (customImports.Length == 0) customImports = new string[3] { "System", "System.Diagnostics.Process", "System.IO" };
|
||||
|
||||
try
|
||||
{
|
||||
var inputCode = File.ReadAllText(input);
|
||||
|
||||
var options = ScriptOptions.Default
|
||||
.WithReferences(AppDomain.CurrentDomain.GetAssemblies()) // Add necessary assemblies
|
||||
.WithReferences(typeof(Process).Assembly,
|
||||
typeof(Console).Assembly
|
||||
)
|
||||
.WithOptimizationLevel(Microsoft.CodeAnalysis.OptimizationLevel.Release)
|
||||
.WithImports(customImports)
|
||||
.WithAllowUnsafe(true);
|
||||
|
||||
|
||||
Console.WriteLine("Run Script: " + input);
|
||||
Console.WriteLine("Script Length: " + inputCode.Length);
|
||||
|
||||
|
||||
// Capture console output using custom class
|
||||
using (var consoleOutput = new ConsoleOutput())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue