diff --git a/docs/core/tutorials/debugging-with-visual-studio-code.md b/docs/core/tutorials/debugging-with-visual-studio-code.md
index 04d8a494b906d..fd0c885ab6f5d 100644
--- a/docs/core/tutorials/debugging-with-visual-studio-code.md
+++ b/docs/core/tutorials/debugging-with-visual-studio-code.md
@@ -1,7 +1,7 @@
---
title: Debug a .NET console application using Visual Studio Code
description: Learn how to debug a .NET console app using Visual Studio Code.
-ms.date: 08/30/2023
+ms.date: 07/09/2024
zone_pivot_groups: dotnet-version
---
# Tutorial: Debug a .NET console application using Visual Studio Code
@@ -38,35 +38,21 @@ A *breakpoint* temporarily interrupts the execution of the application before th
:::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set":::
-## Set up for terminal input
-
-The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal.
-
-1. The project folder contains a *.vscode* folder. Open the *launch.json* file that's in the *.vscode* folder.
-
-1. In *launch.json*, change the `console` setting from `internalConsole` to `integratedTerminal`:
-
- ```json
- "console": "integratedTerminal",
- ```
-
-1. Save your changes.
-
## Start debugging
1. Open the Debug view by selecting the Debugging icon on the left side menu.
:::image type="content" source="media/debugging-with-visual-studio-code/select-debug-pane-net6.png" alt-text="Open the Debug tab in Visual Studio Code":::
-1. Select the green arrow at the top of the pane, next to **.NET Core Launch (console)**. Other ways to start the program in debugging mode are by pressing F5 or choosing **Run** > **Start Debugging** from the menu.
+1. Select **Run and Debug**. If asked, select **C#** and then select **C#: Launch startup project**. Other ways to start the program in debugging mode are by pressing F5 or choosing **Run** > **Start Debugging** from the menu.
:::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging":::
-1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
+1. Select the **Debug Console** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
- :::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab":::
+ :::image type="content" source="media/debugging-with-visual-studio-code/select-debug-console.png" alt-text="Select the Debug Console tab":::
-1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter.
+1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter.
Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method.
@@ -90,8 +76,6 @@ The **Debug Console** window lets you interact with the application you're debug
:::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging":::
-1. Select the **Terminal** tab again.
-
The values displayed in the console window correspond to the changes you made in the **Debug Console**.
:::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values":::
@@ -120,7 +104,7 @@ The program displays the string that the user enters. What happens if the user d
1. Start the program with debugging by pressing F5.
-1. In the **Terminal** tab, press the Enter key when prompted to enter your name.
+1. In the **Debug Console** tab, press the Enter key when prompted to enter your name.
Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs.
@@ -134,7 +118,7 @@ The program displays the string that the user enters. What happens if the user d
1. Select the **Continue** button on the toolbar to continue program execution.
-1. Select the **Terminal** tab, and press any key to exit the program and stop debugging.
+1. Press any key to exit the program and stop debugging.
1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected.
@@ -168,7 +152,7 @@ Visual Studio Code also allows you to step line by line through a program and mo
1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter.
- The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input.
+ The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input.
1. Select **Run** > **Step Into** or press F11.
@@ -186,8 +170,6 @@ Visual Studio Code also allows you to step line by line through a program and mo
:::image type="content" source="media/debugging-with-visual-studio-code/step-out.png" alt-text="Step-Out button":::
-1. Select the **Terminal** tab.
-
The terminal displays "Press any key to exit..."
1. Press any key to exit the program.
@@ -247,20 +229,6 @@ A *breakpoint* temporarily interrupts the execution of the application before th
:::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set":::
-## Set up for terminal input
-
-The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal.
-
-1. The project folder contains a *.vscode* folder. Open the *launch.json* file that's in the *.vscode* folder.
-
-1. In *launch.json*, change the `console` setting from `internalConsole` to `integratedTerminal`:
-
- ```json
- "console": "integratedTerminal",
- ```
-
-1. Save your changes.
-
## Start debugging
1. Open the Debug view by selecting the Debugging icon on the left side menu.
@@ -271,11 +239,11 @@ The breakpoint is located after a `Console.ReadLine` method call. The **Debug Co
:::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging":::
-1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
+1. Select the **Debug Conosle** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
:::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab":::
-1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter.
+1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter.
Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method.
@@ -299,8 +267,6 @@ The **Debug Console** window lets you interact with the application you're debug
:::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging":::
-1. Select the **Terminal** tab again.
-
The values displayed in the console window correspond to the changes you made in the **Debug Console**.
:::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values":::
@@ -329,7 +295,7 @@ The program displays the string that the user enters. What happens if the user d
1. Start the program with debugging by pressing F5.
-1. In the **Terminal** tab, press the Enter key when prompted to enter your name.
+1. In the **Debug Console** tab, press the Enter key when prompted to enter your name.
Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs.
@@ -343,7 +309,7 @@ The program displays the string that the user enters. What happens if the user d
1. Select the **Continue** button on the toolbar to continue program execution.
-1. Select the **Terminal** tab, and press any key to exit the program and stop debugging.
+1. Press any key to exit the program and stop debugging.
1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected.
@@ -377,7 +343,7 @@ Visual Studio Code also allows you to step line by line through a program and mo
1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter.
- The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input.
+ The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input.
1. Select **Run** > **Step Into** or press F11.
@@ -456,20 +422,6 @@ A *breakpoint* temporarily interrupts the execution of the application before th
:::image type="content" source="media/debugging-with-visual-studio-code/breakpoint-set-net6.png" alt-text="Breakpoint set":::
-## Set up for terminal input
-
-The breakpoint is located after a `Console.ReadLine` method call. The **Debug Console** doesn't accept terminal input for a running program. To handle terminal input while debugging, you can use the integrated terminal (one of the Visual Studio Code windows) or an external terminal. For this tutorial, you use the integrated terminal.
-
-1. Open *.vscode/launch.json*.
-
-1. Change the `console` setting from `internalConsole` to `integratedTerminal`:
-
- ```json
- "console": "integratedTerminal",
- ```
-
-1. Save your changes.
-
## Start debugging
1. Open the Debug view by selecting the Debugging icon on the left side menu.
@@ -480,11 +432,11 @@ The breakpoint is located after a `Console.ReadLine` method call. The **Debug Co
:::image type="content" source="media/debugging-with-visual-studio-code/start-debugging.png" alt-text="Start debugging":::
-1. Select the **Terminal** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
+1. Select the **Debug Console** tab to see the "What is your name?" prompt that the program displays before waiting for a response.
:::image type="content" source="media/debugging-with-visual-studio-code/select-terminal-net6.png" alt-text="Select the Terminal tab":::
-1. Enter a string in the **Terminal** window in response to the prompt for a name, and then press Enter.
+1. Enter a string in the **Debug Console** window in response to the prompt for a name, and then press Enter.
Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs. The **Locals** section of the **Variables** window displays the values of variables that are defined in the currently running method.
@@ -508,8 +460,6 @@ The **Debug Console** window lets you interact with the application you're debug
:::image type="content" source="media/debugging-with-visual-studio-code/continue-debugging.png" alt-text="Continue debugging":::
-1. Select the **Terminal** tab again.
-
The values displayed in the console window correspond to the changes you made in the **Debug Console**.
:::image type="content" source="media/debugging-with-visual-studio-code/changed-variable-values.png" alt-text="Terminal showing the entered values":::
@@ -538,7 +488,7 @@ The program displays the string that the user enters. What happens if the user d
1. Start the program with debugging by pressing F5.
-1. In the **Terminal** tab, press the Enter key when prompted to enter your name.
+1. In the **Debug Console** tab, press the Enter key when prompted to enter your name.
Because the condition you specified (`name` is either `null` or ) has been satisfied, program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method runs.
@@ -552,7 +502,7 @@ The program displays the string that the user enters. What happens if the user d
1. Select the **Continue** button on the toolbar to continue program execution.
-1. Select the **Terminal** tab, and press any key to exit the program and stop debugging.
+1. Press any key to exit the program and stop debugging.
1. Clear the breakpoint by clicking on the dot in the left margin of the code window. Other ways to clear a breakpoint are by pressing F9 or choosing **Run > Toggle Breakpoint** from the menu while the line of code is selected.
@@ -586,7 +536,7 @@ Visual Studio Code also allows you to step line by line through a program and mo
1. Respond to the prompt by entering a string in the Terminal tab and pressing Enter.
- The **Terminal** tab might not display the string you enter while you're entering it, but the method will capture your input.
+ The **Debug Console** tab might not display the string you enter while you're entering it, but the method will capture your input.
The **Variables** window shows the value returned by the call to the method.
@@ -606,8 +556,6 @@ Visual Studio Code also allows you to step line by line through a program and mo
:::image type="content" source="media/debugging-with-visual-studio-code/step-out.png" alt-text="Step-Out button":::
-1. Select the **Terminal** tab.
-
The terminal displays "Press any key to exit..."
1. Press any key to exit the program.
diff --git a/docs/core/tutorials/library-with-visual-studio-code.md b/docs/core/tutorials/library-with-visual-studio-code.md
index b3db62834635f..4d7f768079bcd 100644
--- a/docs/core/tutorials/library-with-visual-studio-code.md
+++ b/docs/core/tutorials/library-with-visual-studio-code.md
@@ -1,7 +1,7 @@
---
title: Create a .NET class library using Visual Studio Code
description: Learn how to create a .NET class library using Visual Studio Code.
-ms.date: 08/30/2023
+ms.date: 06/14/2024
zone_pivot_groups: dotnet-version
---
# Tutorial: Create a .NET class library using Visual Studio Code
@@ -16,74 +16,27 @@ When you create a class library, you can distribute it as a third-party componen
## Prerequisites
-* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed.
-
- If you have the [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed, uninstall or disable it. It isn't used by this tutorial series.
+* [Visual Studio Code](https://code.visualstudio.com/) 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).
* The [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
-## Create a solution
-
-Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
-
-1. Start Visual Studio Code.
-
-1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu
-
-1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS).
-
-1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
-
- The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder.
-
-1. In the **Terminal**, enter the following command:
-
- ```dotnetcli
- dotnet new sln
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Solution File" was created successfully.
- ```
-
## Create a class library project
-Add a new .NET class library project named "StringLibrary" to the solution.
-
-1. In the terminal, run the following command to create the library project:
-
- ```dotnetcli
- dotnet new classlib -o StringLibrary
- ```
-
- The `-o` or `--output` command specifies the location to place the generated output.
+Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
- The terminal output looks like the following example:
+1. Start Visual Studio Code.
- ```output
- The template "Class library" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on StringLibrary\StringLibrary.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms).
- Restore succeeded.
- ```
+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.
-1. Run the following command to add the library project to the solution:
+1. After selecting the command, you'll need to choose the project template. Choose Class Library.
- ```dotnetcli
- dotnet sln add StringLibrary/StringLibrary.csproj
- ```
+1. Then select the location where you would like the new project to be created.
- The terminal output looks like the following example:
+1. Give it the name **StringLibrary** and select **Create Project**.
- ```output
- Project `StringLibrary\StringLibrary.csproj` added to the solution.
- ```
+1. Press Enter at the prompt **Project will be created in \**.
1. Check to make sure that the library targets .NET 8. In **Explorer**, open *StringLibrary/StringLibrary.csproj*.
@@ -109,11 +62,9 @@ Add a new .NET class library project named "StringLibrary" to the solution.
1. Save the file.
-1. Run the following command to build the solution and verify that the project compiles without error.
+1. Expand **Solution Explorer** at the bottom of the **Explorer** view.
- ```dotnetcli
- dotnet build
- ```
+1. Right click the solution in **Solution Explorer** and select **Build**, or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error.
The terminal output looks like the following example:
@@ -133,34 +84,11 @@ Add a new .NET class library project named "StringLibrary" to the solution.
Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character.
-1. In the terminal, run the following command to create the console app project:
+1. Right-click the solution in **Solution Explorer** and select **New Project**, or in the Command Palette select **.NET: New Project**.
- ```dotnetcli
- dotnet new console -o ShowCase
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Console Application" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on ShowCase\ShowCase.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms).
- Restore succeeded.
- ```
+1. Select Console app.
-1. Run the following command to add the console app project to the solution:
-
- ```dotnetcli
- dotnet sln add ShowCase/ShowCase.csproj
- ```
-
- The terminal output looks like the following example:
-
- ```output
- Project `ShowCase\ShowCase.csproj` added to the solution.
- ```
+1. Give it the name **ShowCase**, select the default location and select **Create Project**.
1. Open *ShowCase/Program.cs* and replace all of the code with the following code.
@@ -176,25 +104,17 @@ Add a console application that uses the class library. The app will prompt the u
Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project.
-1. Run the following command:
-
- ```dotnetcli
- dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj
- ```
-
- The terminal output looks like the following example:
+1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**.
- ```output
- Reference `..\StringLibrary\StringLibrary.csproj` added to the project.
- ```
+1. Select StringLibrary.
## Run the app
-1. Run the following command in the terminal:
+1. Select **Run** > **Run without debugging**.
- ```dotnetcli
- dotnet run --project ShowCase/ShowCase.csproj
- ```
+1. Select C#.
+
+1. Select ShowCase.
1. Try out the program by entering strings and pressing Enter, then press Enter to exit.
@@ -219,7 +139,7 @@ Initially, the new console app project doesn't have access to the class library.
## Next steps
-In this tutorial, you created a solution, added a library project, and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution.
+In this tutorial, you created a library project and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution.
> [!div class="nextstepaction"]
> [Test a .NET class library with .NET using Visual Studio Code](testing-library-with-visual-studio-code.md)
@@ -236,69 +156,22 @@ When you create a class library, you can distribute it as a third-party componen
## Prerequisites
-* [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).
+* [Visual Studio Code](https://code.visualstudio.com/) 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).
* The [.NET 7 SDK](https://dotnet.microsoft.com/download/dotnet/7.0).
-## Create a solution
+## Create a class library project and solution
-Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
+Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
1. Start Visual Studio Code.
-1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu
-
-1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS).
-
-1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
-
- The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder.
-
-1. In the **Terminal**, enter the following command:
-
- ```dotnetcli
- dotnet new sln
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Solution File" was created successfully.
- ```
-
-## Create a class library project
-
-Add a new .NET class library project named "StringLibrary" to the solution.
-
-1. In the terminal, run the following command to create the library project:
-
- ```dotnetcli
- dotnet new classlib -o StringLibrary
- ```
+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.
- The `-o` or `--output` command specifies the location to place the generated output.
+1. After selecting the command, you'll need to choose the project template. Choose Class Library.
- The terminal output looks like the following example:
-
- ```output
- The template "Class library" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on StringLibrary\StringLibrary.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms).
- Restore succeeded.
- ```
+1. Then select the location where you would like the new project to be created.
-1. Run the following command to add the library project to the solution:
-
- ```dotnetcli
- dotnet sln add StringLibrary/StringLibrary.csproj
- ```
-
- The terminal output looks like the following example:
-
- ```output
- Project `StringLibrary\StringLibrary.csproj` added to the solution.
- ```
+1. Give it the name **StringLibrary**, select **Show all template options**, select **.NET 7** and select **Create Project**.
1. Check to make sure that the library targets .NET 7. In **Explorer**, open *StringLibrary/StringLibrary.csproj*.
@@ -324,11 +197,7 @@ Add a new .NET class library project named "StringLibrary" to the solution.
1. Save the file.
-1. Run the following command to build the solution and verify that the project compiles without error.
-
- ```dotnetcli
- dotnet build
- ```
+1. Right click on the project in **Solution Explorer** and right-click **Build** or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error.
The terminal output looks like the following example:
@@ -348,34 +217,11 @@ Add a new .NET class library project named "StringLibrary" to the solution.
Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character.
-1. In the terminal, run the following command to create the console app project:
-
- ```dotnetcli
- dotnet new console -o ShowCase
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Console Application" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on ShowCase\ShowCase.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms).
- Restore succeeded.
- ```
-
-1. Run the following command to add the console app project to the solution:
-
- ```dotnetcli
- dotnet sln add ShowCase/ShowCase.csproj
- ```
+1. In the **Solution Explorer** select **New Project** or in the Command Palette select **.NET: New Project**.
- The terminal output looks like the following example:
+1. Select Console app.
- ```output
- Project `ShowCase\ShowCase.csproj` added to the solution.
- ```
+1. Give it the name **ShowCase**, select the default location and select **Create Project**.
1. Open *ShowCase/Program.cs* and replace all of the code with the following code.
@@ -391,25 +237,17 @@ Add a console application that uses the class library. The app will prompt the u
Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project.
-1. Run the following command:
-
- ```dotnetcli
- dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj
- ```
-
- The terminal output looks like the following example:
+1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**.
- ```output
- Reference `..\StringLibrary\StringLibrary.csproj` added to the project.
- ```
+1. Select StringLibrary.
## Run the app
-1. Run the following command in the terminal:
+1. Select Run>Run without debugging.
- ```dotnetcli
- dotnet run --project ShowCase/ShowCase.csproj
- ```
+1. Select C#.
+
+1. Select ShowCase.
1. Try out the program by entering strings and pressing Enter, then press Enter to exit.
@@ -451,71 +289,22 @@ When you create a class library, you can distribute it as a third-party componen
## Prerequisites
-* [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).
+* [Visual Studio Code](https://code.visualstudio.com/) 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).
* The [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0).
-## Create a solution
+## Create a class library project and solution
-Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
+Start by creating a .NET class library project named "StringLibrary" and an associated solution. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
1. Start Visual Studio Code.
-1. Select **File** > **Open Folder** (**Open...** on macOS) from the main menu
-
-1. In the **Open Folder** dialog, create a *ClassLibraryProjects* folder and click **Select Folder** (**Open** on macOS).
-
-1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
-
- The **Terminal** opens with the command prompt in the *ClassLibraryProjects* folder.
-
-1. In the **Terminal**, enter the following command:
-
- ```dotnetcli
- dotnet new sln
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Solution File" was created successfully.
- ```
-
-## Create a class library project
-
-Add a new .NET class library project named "StringLibrary" to the solution.
+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.
-1. In the terminal, run the following command to create the library project:
+1. After selecting the command, you'll need to choose the project template. Choose Class Library.
- ```dotnetcli
- dotnet new classlib -f net6.0 -o StringLibrary
- ```
-
- The `-f` or `--framework` command changes the default target framework to `net6.0` version.
-
- The `-o` or `--output` command specifies the location to place the generated output.
-
- The terminal output looks like the following example:
-
- ```output
- The template "Class library" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on StringLibrary\StringLibrary.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\StringLibrary\StringLibrary.csproj (in 328 ms).
- Restore succeeded.
- ```
-
-1. Run the following command to add the library project to the solution:
+1. Then select the location where you would like the new project to be created.
- ```dotnetcli
- dotnet sln add StringLibrary/StringLibrary.csproj
- ```
-
- The terminal output looks like the following example:
-
- ```output
- Project `StringLibrary\StringLibrary.csproj` added to the solution.
- ```
+1. Give it the name **StringLibrary**, select **Show all template options**, select **.NET 7** and select **Create Project**.
1. Check to make sure that the library targets .NET 6. In **Explorer**, open *StringLibrary/StringLibrary.csproj*.
@@ -541,11 +330,7 @@ Add a new .NET class library project named "StringLibrary" to the solution.
1. Save the file.
-1. Run the following command to build the solution and verify that the project compiles without error.
-
- ```dotnetcli
- dotnet build
- ```
+1. Right click on the project in **Solution Explorer** and right-click **Build** or open the Command Palette and select **.NET: Build** to build the solution and verify that the project compiles without error.
The terminal output looks like the following example:
@@ -565,34 +350,11 @@ Add a new .NET class library project named "StringLibrary" to the solution.
Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character.
-1. In the terminal, run the following command to create the console app project:
-
- ```dotnetcli
- dotnet new console -f net6.0 -o ShowCase
- ```
-
- The terminal output looks like the following example:
-
- ```output
- The template "Console Application" was created successfully.
- Processing post-creation actions...
- Running 'dotnet restore' on ShowCase\ShowCase.csproj...
- Determining projects to restore...
- Restored C:\Projects\ClassLibraryProjects\ShowCase\ShowCase.csproj (in 210 ms).
- Restore succeeded.
- ```
-
-1. Run the following command to add the console app project to the solution:
+1. In the **Solution Explorer** select **New Project** or in the Command Palette select **.NET: New Project**.
- ```dotnetcli
- dotnet sln add ShowCase/ShowCase.csproj
- ```
-
- The terminal output looks like the following example:
+1. Select Console app.
- ```output
- Project `ShowCase\ShowCase.csproj` added to the solution.
- ```
+1. Give it the name **ShowCase**, select the default location and select **Create Project**.
1. Open *ShowCase/Program.cs* and replace all of the code with the following code.
@@ -608,25 +370,17 @@ Add a console application that uses the class library. The app will prompt the u
Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project.
-1. Run the following command:
-
- ```dotnetcli
- dotnet add ShowCase/ShowCase.csproj reference StringLibrary/StringLibrary.csproj
- ```
-
- The terminal output looks like the following example:
+1. In **Solution Explorer** right click on the **ShowCase** project and select **Add Project Reference**.
- ```output
- Reference `..\StringLibrary\StringLibrary.csproj` added to the project.
- ```
+1. Select StringLibrary.
## Run the app
-1. Run the following command in the terminal:
+1. Select Run>Run without debugging.
- ```dotnetcli
- dotnet run --project ShowCase/ShowCase.csproj
- ```
+1. Select C#.
+
+1. Select ShowCase.
1. Try out the program by entering strings and pressing Enter, then press Enter to exit.
diff --git a/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png b/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png
new file mode 100644
index 0000000000000..0fbb26f2f429e
Binary files /dev/null and b/docs/core/tutorials/media/debugging-with-visual-studio-code/select-debug-console.png differ
diff --git a/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png b/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png
index 29b693b3729bc..e7227949661b3 100644
Binary files a/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png and b/docs/core/tutorials/media/debugging-with-visual-studio-code/start-debugging.png differ
diff --git a/docs/core/tutorials/testing-library-with-visual-studio-code.md b/docs/core/tutorials/testing-library-with-visual-studio-code.md
index b92ae6997d5a3..3b579f832a710 100644
--- a/docs/core/tutorials/testing-library-with-visual-studio-code.md
+++ b/docs/core/tutorials/testing-library-with-visual-studio-code.md
@@ -1,7 +1,7 @@
---
title: Test a .NET class library using Visual Studio Code
-description: Learn how to use Visual Studio Code and the .NET CLI to create and run a unit test project for a .NET class library.
-ms.date: 09/01/2023
+description: Learn how to use Visual Studio Code and run a unit test project for a .NET class library.
+ms.date: 06/14/2024
zone_pivot_groups: dotnet-version
---
# Tutorial: Test a .NET class library using Visual Studio Code
@@ -22,11 +22,9 @@ Unit tests provide automated software testing during your development and publis
1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md).
-1. Create a unit test project named "StringLibraryTest".
+1. From **Solution Explorer**, select **New Project**, or from the Command Palette select **.NET: New Project**.
- ```dotnetcli
- dotnet new mstest -o StringLibraryTest
- ```
+1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**.
The project template creates a *UnitTest1.cs* file with the following code:
@@ -51,21 +49,13 @@ Unit tests provide automated software testing during your development and publis
Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked.
-1. Add the test project to the solution.
-
- ```dotnetcli
- dotnet sln add StringLibraryTest/StringLibraryTest.csproj
- ```
-
## Add a project reference
For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project.
-1. Run the following command:
+1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**.
- ```dotnetcli
- dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj
- ```
+1. Select "StringLibrary".
## Add and run unit test methods
@@ -98,20 +88,13 @@ To create the test methods:
1. Save your changes.
-1. Run the tests:
+## Build and Run your Tests
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
+1. In **Solution Explorer**, right-click the solution and select **Build** or from the Command Palette, select **.NET: Build**.
- The terminal output shows that all tests passed.
+1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**.
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
-
- Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net8.0)
- ```
+ :::image type="content" source="testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer":::
## Handle test failures
@@ -124,27 +107,15 @@ If you're doing test-driven development (TDD), you write tests first and they fa
"1234", ".", ";", " " };
```
-1. Run the tests:
+1. Run the tests by clicking on the green error next to the test in the editor.
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
+ The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
- The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
+ :::image type="content" source="testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test":::
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
- Failed TestDoesNotStartWithUpper [28 ms]
- Error Message:
- Assert.IsFalse failed. Expected for 'Error': false; Actual: True
- Stack Trace:
- at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
+1. Remove the string "Error" that you added in step.
- Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0)
- ```
-
-1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass.
+1. Rerun the test and the tests pass.
## Test the Release version of the library
@@ -160,7 +131,7 @@ Now that the tests have all passed when running the Debug build of the library,
## Debug tests
-If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
+If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.
@@ -208,11 +179,9 @@ Unit tests provide automated software testing during your development and publis
1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md).
-1. Create a unit test project named "StringLibraryTest".
+1. From **Solution Explorer**, select **Add Project**, or from the Command Palette select **.NET: New Project**.
- ```dotnetcli
- dotnet new mstest -o StringLibraryTest
- ```
+1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**.
The project template creates a UnitTest1.cs file with the following code:
@@ -240,21 +209,13 @@ Unit tests provide automated software testing during your development and publis
Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked.
-1. Add the test project to the solution.
-
- ```dotnetcli
- dotnet sln add StringLibraryTest/StringLibraryTest.csproj
- ```
-
## Add a project reference
For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project.
-1. Run the following command:
+1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**.
- ```dotnetcli
- dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj
- ```
+1. Select "StringLibrary".
## Add and run unit test methods
@@ -287,20 +248,13 @@ To create the test methods:
1. Save your changes.
-1. Run the tests:
+## Build and Run your Tests
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
+1. In **Solution Explorer**, right-click and select **Build** or from the Command Palette, select **.NET: Build**.
- The terminal output shows that all tests passed.
+1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**.
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
-
- Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net7.0)
- ```
+ :::image type="content" source="media/testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer":::
## Handle test failures
@@ -313,25 +267,11 @@ If you're doing test-driven development (TDD), you write tests first and they fa
"1234", ".", ";", " " };
```
-1. Run the tests:
+1. Run the tests by clicking on the green error next to the test in the editor.
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
+ The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
- The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
-
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
- Failed TestDoesNotStartWithUpper [28 ms]
- Error Message:
- Assert.IsFalse failed. Expected for 'Error': false; Actual: True
- Stack Trace:
- at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
-
- Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0)
- ```
+ :::image type="content" source="media/testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test":::
1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass.
@@ -349,7 +289,7 @@ Now that the tests have all passed when running the Debug build of the library,
## Debug tests
-If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
+If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.
@@ -392,15 +332,9 @@ Unit tests provide automated software testing during your development and publis
1. Open the `ClassLibraryProjects` solution you created in [Create a .NET class library using Visual Studio Code](library-with-visual-studio-code.md).
-1. Create a unit test project named "StringLibraryTest".
+1. From **Solution Explorer**, select **Add Project**, or from the Command Palette select **.NET: New Project**.
- ```dotnetcli
- dotnet new mstest -f net6.0 -o StringLibraryTest
- ```
-
- The `-f net6.0` command changes the default target framework to `net6.0` version.
-
- The `-o` or `--output` command specifies the location to place the generated output.
+1. Select **MSTest Test Project**, name it "StringLibraryTest", select the default directory, and select **Create Project**.
The project template creates a UnitTest1.cs file with the following code:
@@ -428,21 +362,13 @@ Unit tests provide automated software testing during your development and publis
Each method tagged with [[TestMethod]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute) in a test class tagged with [[TestClass]](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute) is run automatically when the unit test is invoked.
-1. Add the test project to the solution.
-
- ```dotnetcli
- dotnet sln add StringLibraryTest/StringLibraryTest.csproj
- ```
-
## Add a project reference
For the test project to work with the `StringLibrary` class, add a reference in the `StringLibraryTest` project to the `StringLibrary` project.
-1. Run the following command:
+1. From **Solution Explorer** right click on the 'StringLibraryTest' Project and select **Add Project Reference**.
- ```dotnetcli
- dotnet add StringLibraryTest/StringLibraryTest.csproj reference StringLibrary/StringLibrary.csproj
- ```
+1. Select "StringLibrary".
## Add and run unit test methods
@@ -475,20 +401,13 @@ To create the test methods:
1. Save your changes.
-1. Run the tests:
+## Build and Run your Tests
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
+1. In **Solution Explorer**, right-click and select **Build** or from the Command Palette, select **.NET: Build**.
- The terminal output shows that all tests passed.
+1. Select the **Testing** window, select **Run Tests** or from the Command Palette, select **Test: Run all Tests**.
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
-
- Passed! - Failed: 0, Passed: 3, Skipped: 0, Total: 3, Duration: 3 ms - StringLibraryTest.dll (net6.0)
- ```
+ :::image type="content" source="media/testing-library-with-visual-studio-code/testingScreenshot.png" alt-text="Visual Studio Code Test Explorer":::
## Handle test failures
@@ -501,25 +420,11 @@ If you're doing test-driven development (TDD), you write tests first and they fa
"1234", ".", ";", " " };
```
-1. Run the tests:
-
- ```dotnetcli
- dotnet test StringLibraryTest/StringLibraryTest.csproj
- ```
-
- The terminal output shows that one test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
+1. Run the tests by clicking on the green error next to the test in the editor.
- ```output
- Starting test execution, please wait...
- A total of 1 test files matched the specified pattern.
- Failed TestDoesNotStartWithUpper [28 ms]
- Error Message:
- Assert.IsFalse failed. Expected for 'Error': false; Actual: True
- Stack Trace:
- at StringLibraryTest.UnitTest1.TestDoesNotStartWithUpper() in C:\ClassLibraryProjects\StringLibraryTest\UnitTest1.cs:line 33
+ The output shows that the test fails, and it provides an error message for the failed test: "Assert.IsFalse failed. Expected for 'Error': false; actual: True". Because of the failure, no strings in the array after "Error" were tested.
- Failed! - Failed: 1, Passed: 2, Skipped: 0, Total: 3, Duration: 31 ms - StringLibraryTest.dll (net5.0)
- ```
+ :::image type="content" source="media/testing-library-with-visual-studio-code/failedTest.png" alt-text="Visual Studio Code Failed Test":::
1. Remove the string "Error" that you added in step 1. Rerun the test and the tests pass.
@@ -537,7 +442,7 @@ Now that the tests have all passed when running the Debug build of the library,
## Debug tests
-If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug All Tests** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
+If you're using Visual Studio Code as your IDE, you can use the same process shown in [Debug a .NET console application using Visual Studio Code](debugging-with-visual-studio-code.md) to debug code using your unit test project. Instead of starting the *ShowCase* app project, open *StringLibraryTest/UnitTest1.cs*, and select **Debug Tests in current file** between lines 7 and 8. If you're unable to find it, press Ctrl+Shift+P to open the command palette and enter **Reload Window**.
Visual Studio Code starts the test project with the debugger attached. Execution will stop at any breakpoint you've added to the test project or the underlying library code.
diff --git a/docs/core/tutorials/testing-library-with-visual-studio-code/FailedTest.png b/docs/core/tutorials/testing-library-with-visual-studio-code/FailedTest.png
new file mode 100644
index 0000000000000..9d616e6e742a3
Binary files /dev/null and b/docs/core/tutorials/testing-library-with-visual-studio-code/FailedTest.png differ
diff --git a/docs/core/tutorials/testing-library-with-visual-studio-code/TestingScreenshot.png b/docs/core/tutorials/testing-library-with-visual-studio-code/TestingScreenshot.png
new file mode 100644
index 0000000000000..055af29c8acf7
Binary files /dev/null and b/docs/core/tutorials/testing-library-with-visual-studio-code/TestingScreenshot.png differ
diff --git a/docs/core/tutorials/with-visual-studio-code.md b/docs/core/tutorials/with-visual-studio-code.md
index 7b15bc7190ecf..a9027b921401d 100644
--- a/docs/core/tutorials/with-visual-studio-code.md
+++ b/docs/core/tutorials/with-visual-studio-code.md
@@ -1,20 +1,18 @@
---
title: Create a .NET console application using Visual Studio Code
-description: Learn how to create a .NET console application using Visual Studio Code and the .NET CLI.
-ms.date: 09/21/2023
+description: Learn how to create a .NET console application using Visual Studio Code.
+ms.date: 06/13/2024
zone_pivot_groups: dotnet-version
---
# Tutorial: Create a .NET console application using Visual Studio Code
::: zone pivot="dotnet-8-0"
-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.
+This tutorial shows how to create and run a .NET console application by using Visual Studio Code.
## Prerequisites
-* [Visual Studio Code](https://code.visualstudio.com/) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) installed.
-
- If you have the [C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) installed, uninstall or disable it. It isn't used by this tutorial series.
+* [Visual Studio Code](https://code.visualstudio.com/) with [C# Dev Kit](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).
@@ -26,25 +24,19 @@ Create a .NET console app project named "HelloWorld".
1. Start Visual Studio Code.
-1. Select **File** > **Open Folder** (**File** > **Open...** on macOS) from the main menu.
+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.
-1. In the **Open Folder** dialog, create a *HelloWorld* folder and select it. Then click **Select Folder** (**Open** on macOS).
+1. After selecting the command, you'll need to choose the project template. Choose Console App.
- 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`.
+1. Select the location where you would like the new project to be created.
-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.
-
-1. Open the **Terminal** in Visual Studio Code by selecting **View** > **Terminal** from the main menu.
+1. Give your new project a name, "HelloWorld".
- The **Terminal** opens with the command prompt in the *HelloWorld* folder.
+1. Select to **Show all template options**. Set **Do not use top-level statements** to **true**. And finally, select **Create Project**.
-1. In the **Terminal**, enter the following command:
-
- ```dotnetcli
- dotnet new console --framework net8.0 --use-program-main
- ```
+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.
- Open the *Program.cs* file to see the simple application created by the template:
+1. Open the *Program.cs* file to see the simple application created by the template:
```csharp
namespace HelloWorld;
@@ -58,30 +50,16 @@ Create a .NET console app project named "HelloWorld".
}
```
- The first time you open a *.cs* file, Visual Studio Code prompts you to add assets to build and debug your app. Select **Yes**, and Visual Studio Code creates a *.vscode* folder with *launch.json* and *tasks.json* files.
-
- > [!NOTE]
- > 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*:
- >
- >* Select **Run** > **Add Configuration** from the menu.
- >* Select **.NET 5+ and .NET Core** at the **Select environment** prompt.
-
The code defines a class, `Program`, with a single method, `Main`, that takes a 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. The code in `Main` calls the method to display a message in the console window.
- C# has a feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) that lets you omit the `Program` class and the `Main` method. This tutorial doesn't use this feature. Whether you use it in your programs is a matter of style preference. In the `dotnet new` command that created the project, the `--use-program-main` option prevented top-level statements from being used.
+ C# has a feature named [top-level statements](../../csharp/fundamentals/program-structure/top-level-statements.md) that lets you omit the `Program` class and the `Main` method. This tutorial doesn't use this feature. Whether you use it in your programs is a matter of style preference. By setting **Do not use top-level statements to true** when you created the project, you prevented top-level statements from being used.
## Run the app
-Run the following command in the **Terminal**:
-
-```dotnetcli
-dotnet run
-```
+To run your app, select **Run** > **Run without Debugging** in the upper menu, or use the keyboard shortcut (Ctrl+F5). If asked to select a debugger, select **C#**, then select **C#: Launch startup project HelloWorld**.
The program displays "Hello, World!" and ends.
-
-
## Enhance the app
Enhance the application to prompt the user for their name and display it along with the date and time.
@@ -103,11 +81,7 @@ Enhance the application to prompt the user for their name and display it along w
> [!IMPORTANT]
> 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.
-1. Run the program again:
-
- ```dotnetcli
- dotnet run
- ```
+1. Select **Run**>**Run without debugging**.
1. Respond to the prompt by entering a name and pressing the Enter key.
@@ -182,7 +156,7 @@ Create a .NET console app project named "HelloWorld".
}
```
- 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.
+ 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.
> [!NOTE]
> 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*:
@@ -299,7 +273,7 @@ Create a .NET console app project named "HelloWorld".
}
```
- 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.
+ 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.
> [!NOTE]
> 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*: