public async Task <ObjectResult> JavaPlayGround() { var streamContent = new StreamContent(Request.Body); var codeSnippet = await streamContent.ReadAsStringAsync(); var mainFilePath = $"{JavaFolder}src/main/java/JavaConsole/App.java"; SnippetRunner.FileSplicer(mainFilePath, codeSnippet); var gradle = SnippetRunner.FindExecutable("gradle.exe"); string returnString; if (string.IsNullOrEmpty(gradle))//we are in linux { var buildResponse = SnippetRunner.RunCommand(null, $"./gradlew build", JavaFolder); var runResponse = SnippetRunner.RunCommand(null, "./gradlew run", JavaFolder); returnString = buildResponse + "\r\n\r\n\r\n" + runResponse; } else//we are running in a windows environment { var buildResponse = SnippetRunner.RunCommand(gradle, "build", JavaFolder); var runResponse = SnippetRunner.RunCommand(gradle, "run", JavaFolder); returnString = buildResponse + "\r\n\r\n\r\n" + runResponse; } return(new OkObjectResult(returnString)); }
public async Task <ObjectResult> CsharpPlayGround() { var streamContent = new StreamContent(Request.Body); var codeSnippet = await streamContent.ReadAsStringAsync(); var mainFilePath = $"{ProjectFolder}Program.cs"; SnippetRunner.FileSplicer(mainFilePath, codeSnippet); var dotnet = SnippetRunner.FindExecutable("dotnet.exe"); string returnString; if (string.IsNullOrEmpty(dotnet))//we are in linux { var buildResponse = SnippetRunner.RunCommand(null, $"dotnet build {ProjectFolder}ConsoleApp.csproj", null); var runResponse = SnippetRunner.RunCommand(null, "dotnet run", ProjectFolder); returnString = buildResponse + "\r\n\r\n\r\n" + runResponse; } else//we are running in a windows environment { var buildResponse = SnippetRunner.RunCommand("dotnet", "build", ProjectFolder); var runResponse = SnippetRunner.RunCommand(dotnet, "run", ProjectFolder); returnString = buildResponse + "\r\n\r\n\r\n" + runResponse; } return(new OkObjectResult(returnString)); }