如何在 VSCode (Linux Ubuntu) 中编译和运行 C# 代码? [英] How do I compile and run a C# code in VSCode (Linux Ubuntu)?

查看:174
本文介绍了如何在 VSCode (Linux Ubuntu) 中编译和运行 C# 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很难编译和运行一个简单的 C#Hello World!"代码.在终端中输入dotnet new"什么也不做,输入dotnet new console"只会创建一个 .csproj 文件、一个obj"文件夹和一个 .cs 文件(一个Hello World!"代码),我仍然不能运行.我已经下载了适用于 linux 的 SDK 以及 VSCode 扩展C#"和Code Runner".

I'm really struggling trying to compile and run a simple C# "Hello World!" code. Typing "dotnet new" in the terminal does nothing and typing "dotnet new console" simply creates a .csproj file, a "obj" folder and a .cs file (a "Hello World!" code), which I still can't run it. I've already downloaded SDK for linux and the VSCode extensions "C#" and "Code Runner".

当我尝试使用 Ctrl+Alt+N 时,输出选项卡显示/bin/sh: 1: scriptcs: not found".

When I try using Ctrl+Alt+N the output tab shows "/bin/sh: 1: scriptcs: not found".

推荐答案

在 linux 上,您可以使用 onli .net core(或 Mono,但我不推荐它).

On linux, you can use onli .net core (or Mono, but I not recomend it).

所以,正如这里的解释:https://code.visualstudio.com/docs/languages/dotnet

So, as explaining here: https://code.visualstudio.com/docs/languages/dotnet

对于创建新项目,您应该使用 dotnet new console 命令.

For create new project you should use dotnet new console command.

对于运行:dotnet run

等等.

在 VS Code 中你可以按 Tasks -> Configure tasks并在那里指定您想要做什么.例如,您可以为运行创建任务并将命令 dotnet run 附加到它.

In VS Code you can press Tasks -> Configure tasks And specify there what you want to do. For example you can create task for run and attach command dotnet run to it.

这篇关于如何在 VSCode (Linux Ubuntu) 中编译和运行 C# 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆