Skip to content

Commit

Permalink
Fix Mono 5.0 run under Unity 5.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed Feb 12, 2017
1 parent 8db21b7 commit 2ea0cdd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions extra/UniversalCompiler/Compilers/Mono50Compiler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;

internal class Mono50Compiler : Compiler
{
Expand All @@ -11,17 +12,25 @@ protected override Process CreateCompilerProcess(Platform platform, string monoP
var systemCoreDllPath = Path.Combine(monoProfileDir, "System.Core.dll");

string processArguments;
if (platform == Platform.Windows)
if (platform == Platform.Windows && GetSdkValue(responseFile) == "2.0")
{
processArguments = $"-sdk:2 -debug+ -langversion:Future -r:\"{systemCoreDllPath}\" {responseFile}";
// -sdk:2.0 requires System.Core.dll. but -sdk:unity doesn't.
processArguments = $"-r:\"{systemCoreDllPath}\" {responseFile}";
}
else
{
processArguments = $"-sdk:2 -debug+ -langversion:Future {responseFile}";
processArguments = responseFile;
}

var process = new Process();
process.StartInfo = CreateOSDependentStartInfo(platform, ProcessRuntime.CLR40, compilerPath, processArguments, unityEditorDataDir);
return process;
}

private string GetSdkValue(string responseFile)
{
var lines = File.ReadAllLines(responseFile.Substring(1));
var sdkArg = lines.FirstOrDefault(line => line.StartsWith("-sdk:"));
return (sdkArg != null) ? sdkArg.Substring(5) : "";
}
}

0 comments on commit 2ea0cdd

Please sign in to comment.