Skip to content

Commit

Permalink
Fix compiling not working properly in dotnet build
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Aug 26, 2024
1 parent da4785f commit 3ff3089
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions MCGalaxy/Modules/Compiling/CompilerBackends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public static ICompilerErrors Compile(string[] srcPaths, string dstPath, List<st
string args = GetCommandLineArguments(srcPaths, dstPath, referenced);
string netPath = GetDotnetPath();
string cscPath = GetCompilerPath(netPath);
EnsureFile(netPath);
EnsureFile(cscPath);

ICompilerErrors errors = new ICompilerErrors();
List<string> output = new List<string>();
Expand All @@ -117,6 +119,11 @@ public static ICompilerErrors Compile(string[] srcPaths, string dstPath, List<st
return errors;
}

static void EnsureFile(string path) {
// make sure file exists and can be opened
using (Stream tmp = File.OpenRead(path)) { }
}

static string Quote(string value) { return "\"" + value + "\""; }

static string GetDotnetPath() {
Expand All @@ -131,8 +138,6 @@ static string GetBinaryFile(string varName, string desc) {
if (string.IsNullOrEmpty(path))
throw new InvalidOperationException("Env variable '" + varName + " must specify the path to " + desc);

// make sure file exists
using (Stream tmp = File.OpenRead(path)) { }
return path;
}

Expand All @@ -146,8 +151,10 @@ static string GetCompilerPath(string dotnetPath) {
p.Start();

string sdk = p.StandardOutput.ReadLine();
string sdkVer, sdkPath;
sdk.Separate(' ', out sdkVer, out sdkPath);
p.WaitForExit();
return Path.Combine(rootFolder, "sdk", sdk, "Roslyn", "bincore", "csc.dll");
return Path.Combine(rootFolder, "sdk", sdkVer, "Roslyn", "bincore", "csc.dll");
}
}

Expand Down Expand Up @@ -291,4 +298,4 @@ static string MapAssembly(string[] sysAssemblyPaths, string file) {
}
#endif
}
#endif
#endif

0 comments on commit 3ff3089

Please sign in to comment.