Skip to content

Commit 66a7f3c

Browse files
committed
Reverting the .NET6 and .NET7 sections
1 parent 40ea1a0 commit 66a7f3c

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

docs/core/tutorials/with-visual-studio-code.md

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ In this tutorial, you created a .NET console application. In the next tutorial,
104104

105105
::: zone pivot="dotnet-7-0"
106106

107-
This tutorial shows how to create and run a .NET console application by using Visual Studio Code.
107+
This tutorial shows how to create and run a .NET console application by using Visual Studio Code and the .NET CLI. Project tasks, such as creating, compiling, and running a project are done by using the .NET CLI. You can follow this tutorial with a different code editor and run commands in a terminal if you prefer.
108108

109109
## Prerequisites
110110

111-
* [Visual Studio Code](https://code.visualstudio.com/) with with [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery).
111+
* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed. For information about how to install extensions on Visual Studio Code, see [VS Code Extension Marketplace](https://code.visualstudio.com/docs/editor/extension-gallery).
112112
* The [.NET 7 SDK](https://dotnet.microsoft.com/download/dotnet/7.0).
113113

114114
## Create the app
@@ -117,16 +117,24 @@ Create a .NET console app project named "HelloWorld".
117117

118118
1. Start Visual Studio Code.
119119

120-
1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command.
120+
1. Select **File** > **Open Folder** (**File** > **Open...** on macOS) from the main menu.
121121

122-
1. After selecting the command, you'll need to choose the project template. Choose Console app.
122+
1. In the **Open Folder** dialog, create a *HelloWorld* folder and select it. Then click **Select Folder** (**Open** on macOS).
123123

124-
1. Then select the location where you would like the new project to be created.
125-
126-
1. Give your new project a name, "HelloWorld".
124+
The folder name becomes the project name and the namespace name by default. You'll add code later in the tutorial that assumes the project namespace is `HelloWorld`.
127125

128126
1. In the **Do you trust the authors of the files in this folder?** dialog, select **Yes, I trust the authors**. You can trust the authors because this folder only has files generated by .NET and added or modified by you.
129127

128+
1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
129+
130+
The **Terminal** opens with the command prompt in the *HelloWorld* folder.
131+
132+
1. In the **Terminal**, enter the following command:
133+
134+
```dotnetcli
135+
dotnet new console --framework net7.0
136+
```
137+
130138
The project template creates a simple application that displays "Hello, World" in the console window by calling the <xref:System.Console.WriteLine(System.String)?displayProperty=nameWithType> method in *Program.cs*.
131139

132140
```csharp
@@ -148,13 +156,25 @@ Create a .NET console app project named "HelloWorld".
148156
}
149157
```
150158

159+
The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files.
160+
161+
> [!NOTE]
162+
> If you don't get the prompt, or if you accidentally dismiss it without selecting **Yes**, do the following steps to create *launch.json* and *tasks.json*:
163+
>
164+
>* Select **Run** > **Add Configuration** from the menu.
165+
>* Select **.NET 5+ and .NET Core** at the **Select environment** prompt.
166+
151167
The code defines a class, `Program`, with a single method, `Main`, that takes a <xref:System.String> array as an argument. `Main` is the application entry point, the method that's called automatically by the runtime when it launches the application. Any command-line arguments supplied when the application is launched are available in the *args* array.
152168

153169
In the latest version of C#, a new feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) lets you omit the `Program` class and the `Main` method. Most existing C# programs don't use top-level statements, so this tutorial doesn't use this new feature. But it's available in C# 10, and whether you use it in your programs is a matter of style preference.
154170

155171
## Run the app
156172

157-
To run your app, select Run > Run without Debugging in the upper menu, or use the keyboard shortcut (Ctrl+F5). To learn more about debugging your C# project, read the [debugging documentation](https://code.visualstudio.com/docs/csharp/debugging).
173+
Run the following command in the **Terminal**:
174+
175+
```dotnetcli
176+
dotnet run
177+
```
158178

159179
The program displays "Hello, World!" and ends.
160180

@@ -181,7 +201,11 @@ Enhance the application to prompt the user for their name and display it along w
181201
> [!IMPORTANT]
182202
> In Visual Studio Code, you have to explicitly save changes. Unlike Visual Studio, file changes are not automatically saved when you build and run an app.
183203
184-
1. Select Run>Run without debugging.
204+
1. Run the program again:
205+
206+
```dotnetcli
207+
dotnet run
208+
```
185209

186210
1. Respond to the prompt by entering a name and pressing the <kbd>Enter</kbd> key.
187211

@@ -217,17 +241,23 @@ Create a .NET console app project named "HelloWorld".
217241

218242
1. Start Visual Studio Code.
219243

220-
1. Go to the Explorer view and select **Create .NET Project**. Alternatively, you can bring up the Command Palette using Ctrl+Shift+P (Command+Shift+P on MacOS) and then type ".NET" and find and select the .NET: New Project command.
244+
1. Select **File** > **Open Folder** (**File** > **Open...** on macOS) from the main menu.
221245

222-
1. After selecting the command, you'll need to choose the project template. Choose Console app.
246+
1. In the **Open Folder** dialog, create a *HelloWorld* folder and select it. Then click **Select Folder** (**Open** on macOS).
223247

224-
1. Then select the location where you would like the new project to be created.
248+
The folder name becomes the project name and the namespace name by default. You'll add code later in the tutorial that assumes the project namespace is `HelloWorld`.
225249

226-
1. Finally, give your new project a name, "HelloWorld".
250+
1. In the **Do you trust the authors of the files in this folder?** dialog, select **Yes, I trust the authors**. You can trust the authors because this folder only has files generated by .NET and added or modified by you.
227251

228-
1. Select to **Show all template options**. Set **Do not use top-level statements** to **true**. And finally, select **Create Project**.
252+
1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
229253

230-
1. In the **Do you trust the authors of the files in this folder?** dialog, select **Yes, I trust the authors**. You can trust the authors because this folder only has files generated by .NET and added or modified by you.
254+
The **Terminal** opens with the command prompt in the *HelloWorld* folder.
255+
256+
1. In the **Terminal**, enter the following command:
257+
258+
```dotnetcli
259+
dotnet new console --framework net6.0 --use-program-main
260+
```
231261

232262
The project template creates a simple application that displays "Hello, World" in the console window by calling the <xref:System.Console.WriteLine(System.String)?displayProperty=nameWithType> method in *Program.cs*.
233263

@@ -243,13 +273,25 @@ Create a .NET console app project named "HelloWorld".
243273
}
244274
```
245275

276+
The first time you edit a *.cs* file, Visual Studio Code prompts you to add the missing assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files.
277+
278+
> [!NOTE]
279+
> If you don't get the prompt, or if you accidentally dismiss it without selecting **Yes**, do the following steps to create *launch.json* and *tasks.json*:
280+
>
281+
>* Select **Run** > **Add Configuration** from the menu.
282+
>* Select **.NET 5+ and .NET Core** at the **Select environment** prompt.
283+
246284
The code defines a class, `Program`, with a single method, `Main`, that takes a <xref:System.String> array as an argument. `Main` is the application entry point, the method that's called automatically by the runtime when it launches the application. Any command-line arguments supplied when the application is launched are available in the *args* array.
247285

248286
In the latest version of C#, a new feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) lets you omit the `Program` class and the `Main` method. Most existing C# programs don't use top-level statements, so this tutorial doesn't use this new feature. But it's available in C# 10, and whether you use it in your programs is a matter of style preference. In the `dotnet new` command that you used to create the project, the `--use-program-main` option prevented top-level statements from being used.
249287

250288
## Run the app
251289

252-
To run your app, select Run > Run without Debugging in the upper menu, or use the unassigned keyboard shortcut. To learn more about debugging your C# project, read the [debugging documentation](https://code.visualstudio.com/docs/csharp/debugging).
290+
Run the following command in the **Terminal**:
291+
292+
```dotnetcli
293+
dotnet run
294+
```
253295

254296
The program displays "Hello, World!" and ends.
255297

@@ -276,7 +318,11 @@ Enhance the application to prompt the user for their name and display it along w
276318
> [!IMPORTANT]
277319
> In Visual Studio Code, you have to explicitly save changes. Unlike Visual Studio, file changes are not automatically saved when you build and run an app.
278320
279-
1. Select Run>Run without debugging.
321+
1. Run the program again:
322+
323+
```dotnetcli
324+
dotnet run
325+
```
280326

281327
1. Respond to the prompt by entering a name and pressing the <kbd>Enter</kbd> key.
282328

0 commit comments

Comments
 (0)