Skip to content

Commit fe4df78

Browse files
author
Lucas Bullen
committed
Issue eclipse-acute#66: Run dotnet restore before starting LS
Re-add previously removed workaround for OmniSharp/omnisharp-node-client#265
1 parent 90f1a70 commit fe4df78

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,32 @@ public OmnisharpStreamConnectionProvider() {
4545

4646
@Override
4747
public void start() throws IOException {
48+
// workaround for https://github.com/OmniSharp/omnisharp-node-client/issues/265
49+
String[] command;
50+
try {
51+
command = new String[] { "/bin/bash", "-c", AcutePlugin.getDotnetCommand(), "restore" };
52+
if (Platform.getOS().equals(Platform.OS_WIN32)) {
53+
command = new String[] { "cmd", "/c", AcutePlugin.getDotnetCommand(), "restore" };
54+
}
55+
Process restoreProcess = Runtime.getRuntime().exec(command);
56+
try {
57+
restoreProcess.waitFor();
58+
} catch (InterruptedException e) {
59+
AcutePlugin.logError(e);
60+
}
61+
} catch (IllegalStateException e) {
62+
AcutePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
63+
AcutePlugin.getDefault().getBundle().getSymbolicName(),
64+
"`dotnet restore` not performed!\n"
65+
+ "Main issue and remediation: The `dotnet` path is not set in the .NET Core preferences. Please set it.\n"
66+
+ "Possible alternative remediation:\n"
67+
+ "* `dotnet` (v2.0 or later) is a prerequisite. Install it on your system if missing."));
68+
}
69+
4870
String commandLine = System.getenv("OMNISHARP_LANGUAGE_SERVER_COMMAND");
4971
String omnisharpLocation = System.getenv("OMNISHARP_LANGUAGE_SERVER_LOCATION");
5072
if (commandLine != null) {
51-
String[] command = new String[] {"/bin/bash", "-c", commandLine};
73+
command = new String[] {"/bin/bash", "-c", commandLine};
5274
if (Platform.getOS().equals(Platform.OS_WIN32)) {
5375
command = new String[] {"cmd", "/c", commandLine};
5476
}

0 commit comments

Comments
 (0)