From fe4df78cb88627dd0ffa3d457eb0994feace11c2 Mon Sep 17 00:00:00 2001 From: Lucas Bullen Date: Tue, 21 Nov 2017 10:11:32 -0500 Subject: [PATCH] Issue #66: Run `dotnet restore` before starting LS Re-add previously removed workaround for https://github.com/OmniSharp/omnisharp-node-client/issues/265 --- .../OmnisharpStreamConnectionProvider.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java b/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java index 8c33265d..0e1cd56b 100644 --- a/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java +++ b/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java @@ -45,10 +45,32 @@ public OmnisharpStreamConnectionProvider() { @Override public void start() throws IOException { + // workaround for https://github.com/OmniSharp/omnisharp-node-client/issues/265 + String[] command; + try { + command = new String[] { "/bin/bash", "-c", AcutePlugin.getDotnetCommand(), "restore" }; + if (Platform.getOS().equals(Platform.OS_WIN32)) { + command = new String[] { "cmd", "/c", AcutePlugin.getDotnetCommand(), "restore" }; + } + Process restoreProcess = Runtime.getRuntime().exec(command); + try { + restoreProcess.waitFor(); + } catch (InterruptedException e) { + AcutePlugin.logError(e); + } + } catch (IllegalStateException e) { + AcutePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, + AcutePlugin.getDefault().getBundle().getSymbolicName(), + "`dotnet restore` not performed!\n" + + "Main issue and remediation: The `dotnet` path is not set in the .NET Core preferences. Please set it.\n" + + "Possible alternative remediation:\n" + + "* `dotnet` (v2.0 or later) is a prerequisite. Install it on your system if missing.")); + } + String commandLine = System.getenv("OMNISHARP_LANGUAGE_SERVER_COMMAND"); String omnisharpLocation = System.getenv("OMNISHARP_LANGUAGE_SERVER_LOCATION"); if (commandLine != null) { - String[] command = new String[] {"/bin/bash", "-c", commandLine}; + command = new String[] {"/bin/bash", "-c", commandLine}; if (Platform.getOS().equals(Platform.OS_WIN32)) { command = new String[] {"cmd", "/c", commandLine}; }