❔ Setting up C# in VSCode
So I'm trying to learn c# right now, but when I try to run a test program, it just throws an error:
I have no idea where this "scriptcs" comes from. I ran a search but couldn't find it. What am I doing wrong?
27 Replies
You cant just run a cs file
You need as .csproj
so rename the file?
$vscode
1) Install the C# extension
2)
2.a) DO NOT USE OPEN FILE
2.b) Always use
Open Folder
(from the File
menu), and open the folder containing your .sln
file (or the folder containing the .csproj
if you have only one .csproj
)
3) To make the extension start and detect C#, either:
3.a) wait for the prompt that will appear on the bottom right of your screen that ask you if you want it to create some files, and say Yes
3.b) Command Palette (F1
or Ctrl+Shift+P
) and type > .Net : Generate Assets for build and run
4) you should see a flame on the Status
bar with the Omnisharp logo (see second attached screenshot)
5) it should load to finally say OmniSharp server is running (if not ask for help)
https://media.discordapp.net/attachments/569261465463160900/1006652191689429022/unknown.png
https://cdn.discordapp.com/attachments/569261465463160900/951015732769079336/unknown.pngNo. Create a new project with „dotnet new console“
aight, one sec
You need the .net sdk installed
And then run it with „dotnet run“
This is the minimum for a regular app
Not sure if I did it right. Is this what it's supposed to look like?
Delete the start.csproj
But other than that, yes, looks good
still throws that not recognized error:
Don't use
scriptcs
Use dotnet run
Just dotnet run
As long as you're in the directory the .csproj
is in.
I see it works with dotnet run in terminal... is there a way i can make it work with coderunner?
coderunner?
isnt that what that extension is called?
where you get the run button top right?
This is also valid c#, you dont need a main method, class, namespace etc
read the instructions from Modix again: $vscode
1) Install the C# extension
2)
2.a) DO NOT USE OPEN FILE
2.b) Always use
Open Folder
(from the File
menu), and open the folder containing your .sln
file (or the folder containing the .csproj
if you have only one .csproj
)
3) To make the extension start and detect C#, either:
3.a) wait for the prompt that will appear on the bottom right of your screen that ask you if you want it to create some files, and say Yes
3.b) Command Palette (F1
or Ctrl+Shift+P
) and type > .Net : Generate Assets for build and run
4) you should see a flame on the Status
bar with the Omnisharp logo (see second attached screenshot)
5) it should load to finally say OmniSharp server is running (if not ask for help)
https://media.discordapp.net/attachments/569261465463160900/1006652191689429022/unknown.png
https://cdn.discordapp.com/attachments/569261465463160900/951015732769079336/unknown.pngespecially step 3 to 5
Gotcha, ill try that when i get home
There is a dotnet tool to run scripts actually
GitHub
GitHub - dotnet-script/dotnet-script: Run C# scripts from the .NET ...
Run C# scripts from the .NET CLI. Contribute to dotnet-script/dotnet-script development by creating an account on GitHub.
csx is just a c# file with an x, by convention
ahh, ok, i actually have never used, just heard of it before
it's a weird animal, by the time you're done writing the script you could have just used powershell/python
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.