1 .Open folder
By starting VS Code in a folder, that folder becomes your "workspace". VS Code stores settings that are specific to that workspace in .vscode/settings.json
, which are separate from user settings that are stored globally.
Using a terminal, create an empty folder called "hello", navigate into it, and open VS Code (code) in that folder (.) by entering the following commands:
mkdir hello
cd hello
code .
Alternatively, you can run VS Code through the operating system UI, then use File > Open Folder to open the project folder
2 Create a Hello World app
First, ensure you are within the new folder (workspace) that you created. From here, you can create the project in two ways.
Use the Command Palette
- Bring up the Command Palette using Ctrl+Shift+P and then type ".NET".
- Find and select the .NET: New Project command.
- After selecting the command, you'll need to choose the project template. Choose Console app.
- To run your app, select Run > Start Debugging in the upper menu, or use the F5 keyboard shortcut.
3 Use the terminal
-
Open a terminal/command prompt and navigate to the folder in which you'd like to create the app. Enter the following command in the command shell:
dotnet new console
-
When the project folder is first opened in VS Code:
A "Required assets to build and debug are missing. Add them?" notification appears at the bottom right of the window.
Select Yes.
-
Run the app by entering the following command in the command shell:
dotnet run