Reputation: 1110
I tried to run the csharp code in Visual Studio Code for Mac, I have scripts installed and added to PATH
.
It gives me below error and code cannot run.
[Running] scriptcs "/var/folders/sr/5jzw91rn4g3cc2b0xyhw0j100000gq/T/tempCodeRunnerFile.csharp"
Unexpected named argument: var/folders/sr/5jzw91rn4g3cc2b0xyhw0j100000gq/T/tempCodeRunnerFile.csharp
This is the question linked: Getting error: /bin/sh scriptcs: command not found
The OS version is 10.14.6(18G87) Please see attached screenshot.
The Visual Studio Code version is below:
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:31:32.854Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0
Open Visual Studio Code and create a new File with below code:
using System;
using System.Collections.Generic;
class Test
{
static void Main()
{
foreach (int fib in Fibs(6))
Console.Write (fib + " ");
}
static IEnumerable<int> Fibs (int fibCount)
{
for (int i = 0, prevFib = 1, curFib = 1; i < fibCount; i++)
{
yield return prevFib;
int newFib = prevFib+curFib;
prevFib = curFib;
curFib = newFib;
}
}
}
and then click Run Code on top right in Visual Studio Code.
Upvotes: 0
Views: 1499
Reputation: 27467
This is a bug in PowerArgs, it recognizes an argument started with slash as an option, so you need split the command into two steps.
cd "/var/folders/sr/5jzw91rn4g3cc2b0xyhw0j100000gq/T"
scriptcs "tempCodeRunnerFile.csharp"
[Update] scriptcs is a csharp code runner, to make it work, at least you need one line to call the entry method.
...
class Test
{
public static void Main() // Public
{
...
}
}
Test.Main(); // Run it
Upvotes: 2