Skip to content
Merged
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
32 changes: 9 additions & 23 deletions docs/core/tutorials/debugging-with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Debug a .NET console application using Visual Studio
description: Learn how to debug a .NET console app using Visual Studio.
ms.date: 10/23/2025
ms.date: 01/14/2026
ai-usage: ai-assisted
dev_langs:
- "csharp"
Expand Down Expand Up @@ -43,15 +43,15 @@ 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-net6.png" alt-text="Visual Studio Program window with breakpoint set":::
:::image type="content" source="./media/debugging-with-visual-studio/set-breakpoint-in-editor.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.

1. Enter a string in the console window when the program prompts for a name, and then press <kbd>Enter</kbd>.

1. Program execution stops when it reaches the breakpoint and before the `Console.WriteLine` method executes. The **Locals** window displays the values of variables that are defined in the currently executing method.

:::image type="content" source="./media/debugging-with-visual-studio/breakpoint-hit-net6.png" alt-text="Screenshot of a breakpoint in Visual Studio":::
:::image type="content" source="./media/debugging-with-visual-studio/breakpoint-hit.png" alt-text="Screenshot of a breakpoint in Visual Studio":::

## Use the Immediate window

Expand All @@ -61,18 +61,16 @@ 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("2019-11-16T17:25:00Z").ToUniversalTime()` 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.

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.

:::image type="content" source="./media/debugging-with-visual-studio/locals-immediate-window.png" alt-text="Locals and Immediate Windows in Visual Studio 2019":::
:::image type="content" source="./media/debugging-with-visual-studio/locals-immediate-window.png" alt-text="Locals and Immediate Windows in Visual Studio":::

1. Press <kbd>F5</kbd> to continue program execution. Another way to continue is by choosing **Debug** > **Continue** from the menu.

The values displayed in the console window correspond to the changes you made in the **Immediate** window.

:::image type="content" source="./media/debugging-with-visual-studio/console-window.png" alt-text="Console window showing the entered values":::

1. Press any key to exit the application and stop debugging.

## Set a conditional breakpoint
Expand All @@ -81,9 +79,9 @@ The program displays the string that the user enters. What happens if the user d

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.

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

1. For the **Conditional Expression**, enter the following code in the field that shows example code that tests if `x` is 5.
1. For the **Conditional Expression**, enter the following code in the text field.

```csharp
string.IsNullOrEmpty(name)
Expand Down Expand Up @@ -135,25 +133,13 @@ Visual Studio also allows you to step line by line through a program and monitor

Visual Studio highlights and displays an arrow beside the next line of execution.

C#

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

Visual Basic

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

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.

C#

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

Visual Basic

:::image type="content" source="./media/debugging-with-visual-studio/vb-step-into-source-method.png" alt-text="Visual Studio step into method source - Visual Basic":::
:::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?".

Expand Down
36 changes: 18 additions & 18 deletions docs/core/tutorials/library-with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Create a .NET class library using Visual Studio
description: Learn how to create a .NET class library using Visual Studio.
ms.date: 10/23/2025
ms.date: 01/13/2026
ai-usage: ai-assisted
dev_langs:
- "csharp"
Expand All @@ -12,49 +12,49 @@ ms.custom: vs-dotnet

In this tutorial, you create a simple class library that contains a single string-handling method.

A *class library* defines types and methods that are called by an application. If the library targets .NET Standard 2.0, it can be called by any .NET implementation (including .NET Framework) that supports .NET Standard 2.0. If the library targets .NET 8, it can be called by any application that targets .NET 8. This tutorial shows how to target .NET 8.
A *class library* defines types and methods that an application calls. If the library targets .NET Standard 2.0, any .NET implementation (including .NET Framework) that supports .NET Standard 2.0 can call it. If the library targets .NET 10, any application that targets .NET 10 can call it. This tutorial shows how to target .NET 10.

When you create a class library, you can distribute it as a NuGet package or as a component bundled with the application that uses it.

## Prerequisites

- [Visual Studio 2022 or later](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=learn.microsoft.com&utm_campaign=inline+link) with the **.NET desktop development** workload installed. The .NET SDK is automatically installed when you select this workload.
- [Visual Studio 2026 or later](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=learn.microsoft.com&utm_campaign=inline+link) with the **.NET desktop development** workload installed. The .NET SDK is automatically installed when you select this workload.

For more information, see [Install the .NET SDK with Visual Studio](../install/windows.md#install-with-visual-studio).

## Create a solution

Start by creating a blank solution to put the class library project in. A Visual Studio solution serves as a container for one or more projects. You'll add related projects to the same solution.
Start by creating a blank solution to hold the class library project. A Visual Studio solution serves as a container for one or more projects. Add related projects to the same solution.

To create the blank solution:

1. Start Visual Studio.

2. On the start window, choose **Create a new project**.
1. On the start window, choose **Create a new project**.

3. On the **Create a new project** page, enter **solution** in the search box. Choose the **Blank Solution** template, and then choose **Next**.
1. On the **Create a new project** page, enter **solution** in the search box. Choose the **Blank Solution** template, and then choose **Next**.

:::image type="content" source="media/library-with-visual-studio/blank-solution.png" alt-text="Blank solution template in Visual Studio":::

4. On the **Configure your new project** page, enter **ClassLibraryProjects** in the **Solution name** box. Then choose **Create**.
1. On the **Configure your new project** page, enter **ClassLibraryProjects** in the **Solution name** box. Then choose **Create**.

## Create a class library project

1. Add a new .NET class library project named "StringLibrary" to the solution.
1. Add a new .NET class library project named **StringLibrary** to the solution.

1. Right-click on the solution in **Solution Explorer** and select **Add** > **New Project**.

1. On the **Add a new project** page, enter **library** in the search box. Choose **C#** or **Visual Basic** from the Language list, and then choose **All platforms** from the Platform list. Choose the **Class Library** template, and then choose **Next**.

1. On the **Configure your new project** page, enter **StringLibrary** in the **Project name** box, and then choose **Next**.

1. On the **Additional information** page, select **.NET 8**, and then choose **Create**.
1. On the **Additional information** page, select **.NET 10**, and then choose **Create**.

1. Check to make sure that the library targets the correct version of .NET. Right-click on the library project in **Solution Explorer**, and then select **Properties**. The **Target Framework** text box shows that the project targets .NET 8.0.
1. Check to make sure that the library targets the correct version of .NET. Right-click on the library project in **Solution Explorer**, and then select **Properties**. The **Target Framework** text box shows that the project targets .NET 10.0.

1. If you're using Visual Basic, clear the text in the **Root namespace** text box.
1. If you're using Visual Basic, clear the text in the **Default namespace** text box.

:::image type="content" source="./media/library-with-visual-studio/vb/library-project-properties-net8.png" alt-text="Project properties for the class library":::
:::image type="content" source="./media/library-with-visual-studio/vb/library-project-properties.png" alt-text="Project properties for the class library":::

For each project, Visual Basic automatically creates a namespace that corresponds to the project name. In this tutorial, you define a top-level namespace by using the [`namespace`](../../visual-basic/language-reference/statements/namespace-statement.md) keyword in the code file.

Expand All @@ -71,9 +71,9 @@ To create the blank solution:

## Add a console app 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.
Add a console application that uses the class library. The app prompts the user to enter a string and reports whether the string begins with an uppercase character.

1. Add a new .NET console application named "ShowCase" to the solution.
1. Add a new .NET console application named **ShowCase** to the solution.

1. Right-click on the solution in **Solution Explorer** and select **Add** > **New project**.

Expand All @@ -83,7 +83,7 @@ Add a console application that uses the class library. The app will prompt the u

1. On the **Configure your new project** page, enter **ShowCase** in the **Project name** box. Then choose **Next**.

1. On the **Additional information** page, select **.NET 8** in the **Framework** box. Then choose **Create**.
1. On the **Additional information** page, select **.NET 10** in the **Framework** box. Then choose **Create**.

1. In the code window for the *Program.cs* or *Program.vb* file, replace all of the code with the following code.

Expand Down Expand Up @@ -116,7 +116,7 @@ Initially, the new console app project doesn't have access to the class library.

1. Try out the program by entering strings and pressing <kbd>Enter</kbd>, then press <kbd>Enter</kbd> to exit.

:::image type="content" source="media/library-with-visual-studio/run-showcase-net6.png" alt-text="Console window with ShowCase running":::
:::image type="content" source="media/library-with-visual-studio/run-showcase.png" alt-text="Console window with ShowCase running":::

## Additional resources

Expand All @@ -130,12 +130,12 @@ In this tutorial, you created a class library. In the next tutorial, you learn h
> [!div class="nextstepaction"]
> [Unit test a .NET class library using Visual Studio](testing-library-with-visual-studio.md)

Or you can skip automated unit testing and learn how to share the library by creating a NuGet package:
Or, you can skip automated unit testing and learn how to share the library by creating a NuGet package:

> [!div class="nextstepaction"]
> [Create and publish a package using Visual Studio](/nuget/quickstart/create-and-publish-a-package-using-visual-studio)

Or learn how to publish a console app. If you publish the console app from the solution you created in this tutorial, the class library goes with it as a *.dll* file.
Or, learn how to publish a console app. If you publish the console app from the solution you created in this tutorial, the class library goes with it as a *.dll* file.

> [!div class="nextstepaction"]
> [Publish a .NET console application using Visual Studio](publishing-with-visual-studio.md)
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.
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.
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.
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.
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.
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.
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.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
12 changes: 6 additions & 6 deletions docs/core/tutorials/publishing-with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Publish a .NET console application using Visual Studio
description: Learn how to use Visual Studio to create the set of files that are needed to run a .NET application.
ms.date: 10/23/2025
ms.date: 01/14/2026
ai-usage: ai-assisted
ms.custom:
- "vs-dotnet"
Expand Down Expand Up @@ -39,13 +39,13 @@ This tutorial works with the console app that you create in [Create a .NET conso

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

:::image type="content" source="media/publishing-with-visual-studio/publish-page-loc-tab-net8.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-net8.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

Expand All @@ -55,9 +55,9 @@ 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 the project folder, expand *bin/Release/{net}/publish*. (Where {net} is the target framework folder, such as _net8.0_.)
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-net8.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 Expand Up @@ -88,7 +88,7 @@ In the following steps, you'll look at the files created by the publish process.
1. Open a command prompt and navigate to the *publish* folder. To do that, enter `cd` and then paste the full path. For example:

```console
cd C:\Projects\HelloWorld\bin\Release\net8.0\publish\
cd C:\Projects\HelloWorld\bin\Release\net10.0\publish\
```

1. Run the app by using the executable:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSTest" Version="4.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\StringLibrary\StringLibrary.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using UtilityLibraries;

namespace StringLibraryTest
{
[TestClass]
public sealed class Test1
{
[TestMethod]
public void TestStartsWithUpper()
{
// Tests that we expect to return true.
string[] words = ["Alphabet", "Zebra", "ABC", "Αθήνα", "Москва"];
foreach (var word in words)
{
bool result = word.StartsWithUpper();
Assert.IsTrue(result, $"Expected for '{word}': true; Actual: {result}");
}
}

[TestMethod]
public void TestDoesNotStartWithUpper()
{
// Tests that we expect to return false.
string[] words = ["alphabet", "zebra", "abc", "αυτοκινητοβιομηχανία", "государство",
"1234", ".", ";", " "];
foreach (var word in words)
{
bool result = word.StartsWithUpper();
Assert.IsFalse(result, $"Expected for '{word}': false; Actual: {result}");
}
}

[TestMethod]
public void DirectCallWithNullOrEmpty()
{
// Tests that we expect to return false.
string?[] words = [string.Empty, null];
foreach (var word in words)
{
bool result = StringLibrary.StartsWithUpper(word);
Assert.IsFalse(result, $"Expected for '{word ?? "<null>"}': false; Actual: {result}");
}
}
}
}
Loading