Skip to content

Commit 2ea0cdd

Browse files
committed
Fix Mono 5.0 run under Unity 5.5+
1 parent 8db21b7 commit 2ea0cdd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

extra/UniversalCompiler/Compilers/Mono50Compiler.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics;
22
using System.IO;
3+
using System.Linq;
34

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

1314
string processArguments;
14-
if (platform == Platform.Windows)
15+
if (platform == Platform.Windows && GetSdkValue(responseFile) == "2.0")
1516
{
16-
processArguments = $"-sdk:2 -debug+ -langversion:Future -r:\"{systemCoreDllPath}\" {responseFile}";
17+
// -sdk:2.0 requires System.Core.dll. but -sdk:unity doesn't.
18+
processArguments = $"-r:\"{systemCoreDllPath}\" {responseFile}";
1719
}
1820
else
1921
{
20-
processArguments = $"-sdk:2 -debug+ -langversion:Future {responseFile}";
22+
processArguments = responseFile;
2123
}
2224

2325
var process = new Process();
2426
process.StartInfo = CreateOSDependentStartInfo(platform, ProcessRuntime.CLR40, compilerPath, processArguments, unityEditorDataDir);
2527
return process;
2628
}
29+
30+
private string GetSdkValue(string responseFile)
31+
{
32+
var lines = File.ReadAllLines(responseFile.Substring(1));
33+
var sdkArg = lines.FirstOrDefault(line => line.StartsWith("-sdk:"));
34+
return (sdkArg != null) ? sdkArg.Substring(5) : "";
35+
}
2736
}

0 commit comments

Comments
 (0)