Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions docs/core/tutorials/debugging-with-visual-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ By default, Visual Studio uses the Debug build configuration, so you don't need

The current build configuration is shown on the toolbar. The following toolbar image shows that Visual Studio is configured to compile the Debug version of the app:

:::image type="content" source="./media/debugging-with-visual-studio/visual-studio-toolbar-debug.png" alt-text="Visual Studio toolbar with debug highlighted":::
:::image type="content" source="./media/debugging-with-visual-studio/use-debug-configuration.png" alt-text="Visual Studio toolbar with debug highlighted":::

## Set a breakpoint

Expand All @@ -43,7 +43,7 @@ A *breakpoint* temporarily interrupts the execution of the application before th

As the following image shows, Visual Studio indicates the line on which the breakpoint is set by highlighting it and displaying a red dot in the left margin.

:::image type="content" source="./media/debugging-with-visual-studio/set-breakpoint-in-editor.png" alt-text="Visual Studio Program window with breakpoint set":::
:::image type="content" source="./media/debugging-with-visual-studio/set-breakpoint.png" alt-text="Visual Studio Program window with breakpoint set":::

1. Press <kbd>F5</kbd> to run the program in Debug mode. Another way to start debugging is by choosing **Debug** > **Start Debugging** from the menu.

Expand All @@ -61,7 +61,7 @@ The **Immediate** window lets you interact with the application you're debugging

1. Enter `name = "Gracie"` in the **Immediate** window and press the <kbd>Enter</kbd> key.

1. Enter `currentDate = DateTime.Parse("2026-01-14T17:25:00Z").ToUniversalTime()` in the **Immediate** window and press the <kbd>Enter</kbd> key.
1. Enter `currentDate = DateTime.Parse("2026-02-05T20:25:00Z").ToUniversalTime()` in the **Immediate** window and press the <kbd>Enter</kbd> key.

The **Immediate** window displays the value of the string variable and the properties of the <xref:System.DateTime> value. In addition, the values of the variables are updated in the **Locals** window.

Expand All @@ -77,7 +77,7 @@ The **Immediate** window lets you interact with the application you're debugging

The program displays the string that the user enters. What happens if the user doesn't enter anything? You can test this with a useful debugging feature called a *conditional breakpoint*.

1. Right-click on the red dot that represents the breakpoint. In the context menu, select **Conditions** to open the **Breakpoint Settings** dialog. Select the box for **Conditions** if it's not already selected.
1. Right-click on the red dot that represents the breakpoint. In the context menu, select **Conditions...** to open the **Breakpoint Settings** dialog. Select the box for **Conditions** if it's not already selected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://learn.microsoft.com/en-us/style-guide/procedures-instructions/formatting-text-in-instructions:

"If an option label ends with a colon or an ellipsis, don't include that end punctuation in instructions."


:::image type="content" source="./media/debugging-with-visual-studio/breakpoint-settings.png" alt-text="Editor showing breakpoint settings panel - C#":::

Expand Down Expand Up @@ -129,6 +129,8 @@ The program displays the string that the user enters. What happens if the user d

Visual Studio also allows you to step line by line through a program and monitor its execution. Ordinarily, you'd set a breakpoint and follow program flow through a small part of your program code. Since this program is small, you can step through the entire program.

1. Set a breakpoint on the line of code that displays the "What is your name?" prompt.

1. Choose **Debug** > **Step Into**. Another way to debug one statement at a time is by pressing <kbd>F11</kbd>.

Visual Studio highlights and displays an arrow beside the next line of execution.
Expand All @@ -137,10 +139,6 @@ Visual Studio also allows you to step line by line through a program and monitor

At this point, the **Locals** window shows that the `args` array is empty, and `name` and `currentDate` have default values. In addition, Visual Studio has opened a blank console window.

1. Press <kbd>F11</kbd>. Visual Studio now highlights the next line of execution. The **Locals** window is unchanged, and the console window remains blank.

:::image type="content" source="./media/debugging-with-visual-studio/step-into-source-method.png" alt-text="Visual Studio step in method source - C#":::

1. Press <kbd>F11</kbd>. Visual Studio highlights the statement that includes the `name` variable assignment. The **Locals** window shows that `name` is `null`, and the console window displays the string "What is your name?".

1. Respond to the prompt by entering a string in the console window and pressing <kbd>Enter</kbd>. The console is unresponsive, and the string you entered isn't displayed in the console window, but the <xref:System.Console.ReadLine%2A?displayProperty=nameWithType> method will nevertheless capture your input.
Expand All @@ -163,7 +161,7 @@ Once you've tested the Debug version of your application, you should also compil

To build and test the Release version of your console application, change the build configuration on the toolbar from **Debug** to **Release**.

:::image type="content" source="./media/debugging-with-visual-studio/visual-studio-toolbar-release.png" alt-text="default Visual Studio toolbar with release highlighted":::
:::image type="content" source="./media/debugging-with-visual-studio/use-release-configuration.png" alt-text="default Visual Studio toolbar with release highlighted":::

When you press <kbd>F5</kbd> or choose **Build Solution** from the **Build** menu, Visual Studio compiles the Release version of the application. You can test it as you did the Debug version.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions docs/core/tutorials/publishing-with-visual-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,43 @@ This tutorial works with the console app that you create in [Create a .NET conso

1. Make sure that Visual Studio is using the Release build configuration. If necessary, change the build configuration setting on the toolbar from **Debug** to **Release**.

:::image type="content" source="media/publishing-with-visual-studio/visual-studio-toolbar-release.png" alt-text="Visual Studio toolbar with release build selected":::
:::image type="content" source="media/publishing-with-visual-studio/use-release-configuration.png" alt-text="Visual Studio toolbar with release build selected.":::

1. Right-click on the **HelloWorld** project (not the HelloWorld solution) and select **Publish** from the menu.

:::image type="content" source="media/publishing-with-visual-studio/publish-context-menu.png" alt-text="Visual Studio Publish context menu":::
:::image type="content" source="media/publishing-with-visual-studio/publish-context-menu.png" alt-text="Visual Studio Publish context menu.":::

1. On the **Target** tab of the **Publish** page, select **Folder**, and then select **Next**.

:::image type="content" source="media/publishing-with-visual-studio/pick-publish-target.png" alt-text="Pick a publish target in Visual Studio":::
:::image type="content" source="media/publishing-with-visual-studio/pick-publish-target.png" alt-text="Pick a publish target in Visual Studio.":::

1. On the **Specific Target** tab of the **Publish** page, select **Folder**, and then select **Next**.

:::image type="content" source="media/publishing-with-visual-studio/pick-specific-publish-target.png" alt-text="Pick the specific publish target in Visual Studio":::
:::image type="content" source="media/publishing-with-visual-studio/pick-specific-publish-target.png" alt-text="Pick the specific publish target in Visual Studio.":::

1. On the **Location** tab of the **Publish** page, select **Finish**.

:::image type="content" source="media/publishing-with-visual-studio/publish-page-loc-tab.png" alt-text="Visual Studio Publish page Location tab":::
:::image type="content" source="media/publishing-with-visual-studio/publish-page-loc-tab.png" alt-text="Visual Studio Publish page Location tab.":::

1. On the **Publish profile creation progress** page, select **Close**.

1. On the **Publish** tab of the **Publish** window, select **Publish**.

:::image type="content" source="media/publishing-with-visual-studio/publish-page.png" alt-text="Visual Studio Publish window":::
:::image type="content" source="media/publishing-with-visual-studio/publish-page.png" alt-text="Visual Studio Publish window.":::

## Inspect the files

By default, the publishing process creates a framework-dependent deployment, which is a type of deployment where the published application runs on a machine that has the .NET runtime installed. Users can run the published app by double-clicking the executable or issuing the `dotnet HelloWorld.dll` command from a command prompt.

In the following steps, you'll look at the files created by the publish process.

1. In **Solution Explorer**, select **Show all files**.
1. In **Solution Explorer**, select **Show All Files**.

:::image type="content" source="media/publishing-with-visual-studio/show-all-files.png" alt-text="Solution Explorer option to Show All Files.":::

1. In the project folder, expand *bin/Release/{net}/publish*. (Where {net} is the target framework folder, such as _net10.0_.)

:::image type="content" source="media/publishing-with-visual-studio/published-files-output.png" alt-text="Solution Explorer showing published files":::
:::image type="content" source="media/publishing-with-visual-studio/published-files-output.png" alt-text="Solution Explorer showing published files.":::

As the image shows, the published output includes the following files:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
var name = Console.ReadLine();
var currentDate = DateTime.Now;
Console.WriteLine($"{Environment.NewLine}Hello, {name}, on {currentDate:d} at {currentDate:t}!");
Console.Write($"{Environment.NewLine}Press any key to exit...");
Console.ReadKey(true);
Console.Write($"{Environment.NewLine}Press Enter to exit...");
Console.Read();
// </MainMethod>
24 changes: 8 additions & 16 deletions docs/core/tutorials/with-visual-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,16 @@ Create a .NET console app project named "HelloWorld".
:::image type="content" source="./media/with-visual-studio/configure-new-project.png" alt-text="Configure your new project window with Project name, location, and solution name fields":::

1. In the **Additional information** dialog:
- Select **.NET 10**.
- Select **Do not use top-level statements**.
- Select **.NET 10.0 (Long Term Support)**.
- Select **Create**.

:::image type="content" source="./media/with-visual-studio/additional-information.png" alt-text="Enter additional information for the console app.":::

The template creates a simple application that displays "Hello, World!" in the console window. The code is in the *Program.cs* or *Program.vb* file:

```csharp
namespace HelloWorld;

internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
```

```vb
Expand All @@ -69,9 +63,7 @@ Create a .NET console app project named "HelloWorld".

If the language you want to use is not shown, change the language selector at the top of the page.

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.

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.
The code defines a class, `Program`, that calls the <xref:System.Console.WriteLine(System.String)?displayProperty=nameWithType> method to display a message in the console window.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of agree with CCR here. You can't call a method directly from a class, and I don't see where you're defining the class.


## Run the app

Expand All @@ -85,12 +77,12 @@ Create a .NET console app project named "HelloWorld".

Enhance the application to prompt the user for their name and display it along with the date and time.

1. In *Program.cs* or *Program.vb*, replace the contents of the `Main` method, which is the line that calls `Console.WriteLine`, with the following code:
1. In *Program.cs* or *Program.vb*, replace the contents with the following code:

:::code language="csharp" source="./snippets/with-visual-studio/csharp/Program.cs" id="MainMethod":::
:::code language="vb" source="./snippets/with-visual-studio/vb/Program.vb" id="MainMethod":::

This code displays a prompt in the console window and waits until the user enters a string followed by the <kbd>Enter</kbd> key. It stores this string in a variable named `name`. It also retrieves the value of the <xref:System.DateTime.Now?displayProperty=nameWithType> property, which contains the current local time, and assigns it to a variable named `currentDate`. And it displays these values in the console window. Finally, it displays a prompt in the console window and calls the <xref:System.Console.ReadKey(System.Boolean)?displayProperty=nameWithType> method to wait for user input.
This code displays a prompt in the console window and waits until the user enters a string followed by the <kbd>Enter</kbd> key. It stores this string in a variable named `name`. It also retrieves the value of the <xref:System.DateTime.Now?displayProperty=nameWithType> property, which contains the current local time, and assigns it to a variable named `currentDate`. And it displays these values in the console window. Finally, it displays a prompt in the console window and calls the <xref:System.Console.Read> method to wait for user input.

<xref:System.Environment.NewLine?displayProperty=nameWithType> is a platform-independent and language-independent way to represent a line break. Alternatives are `\n` in C# and `vbCrLf` in Visual Basic.

Expand Down