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
34 changes: 17 additions & 17 deletions docs/core/tutorials/cli-templates-create-item-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ title: Create an item template for dotnet new - .NET CLI
titleSuffix: ""
description: Learn how to create an item template for the dotnet new command. Item templates can contain any number of files.
author: adegeo
ms.date: 09/08/2023
ms.date: 10/23/2025
ai-usage: ai-assisted
ms.topic: tutorial
ms.author: adegeo
---
Expand All @@ -17,7 +18,7 @@ You can view the completed template in the [.NET Samples GitHub repository](http
> [!TIP]
> **Item** templates aren't shown in the **Add** > **New Item** dialog of Visual Studio.

In this part of the series, you'll learn how to:
In this part of the series, you learn how to:

> [!div class="checklist"]
>
Expand All @@ -29,13 +30,11 @@ In this part of the series, you'll learn how to:

## Prerequisites

* [.NET SDK 7.0.100](https://dotnet.microsoft.com/download) or a later version.
- [.NET 9](https://dotnet.microsoft.com/download) or a later version.

The reference article explains the basics about templates and how they're put together. Some of this information is reiterated here.
- The reference article explains the basics about templates and how they're put together. Some of this information is reiterated here.

* Open a terminal and navigate to a folder where you'll store and test the templates.

[!INCLUDE [dotnet6-syntax-note](includes/dotnet6-syntax-note.md)]
- Open a terminal and navigate to a folder where you'll store and test the templates.

## Create the required folders

Expand All @@ -54,7 +53,7 @@ parent_folder

## Create an item template

An item template is a specific type of template that contains one or more files. These types of templates are useful when you already have a project and you want to generate another file, like a config file or code file. In this example, you'll create a class that adds an extension method to the string type.
An item template is a specific type of template that contains one or more files. These types of templates are useful when you already have a project and you want to generate another file, like a config file or code file. In this example, you create a class that adds an extension method to the string type.

In your terminal, navigate to the _working\content_ folder and create a new subfolder named _extensions_.

Expand All @@ -64,7 +63,7 @@ working
└───extensions
```

Navigate to the _extensions_ folder and create a new file named _StringExtensions.cs_. Open the file in a text editor. This class will provide an extension method named `Reverse` that reverses the contents of a string. Paste in the following code and save the file:
Navigate to the _extensions_ folder and create a new file named _StringExtensions.cs_. Open the file in a text editor. This class provides an extension method named `Reverse` that reverses the contents of a string. Paste in the following code and save the file:

```csharp
namespace System;
Expand All @@ -80,7 +79,7 @@ public static class StringExtensions
}
```

Now that the content of the template is finished, the next step is to create the template config.
Now that the content of the template is finished, create the template config.

## Create the template config

Expand Down Expand Up @@ -171,7 +170,7 @@ Template options:
Default: StringExtensions
```

Now that you have a valid _.template.config/template.json_ file, your template is ready to be installed. In your terminal, navigate to the _extensions_ folder and run the following command to install the template located at the current folder:
Now that you have a valid _.template.config/template.json_ file, your template is ready to be installed. In your terminal, navigate to the _extensions_ folder and run the following command to install the template located at the current folder:

* **On Windows**: `dotnet new install .\`
* **On Linux or macOS**: `dotnet new install ./`
Expand All @@ -192,8 +191,9 @@ Example templates: string extensions stringext [C#]

Now that you have an item template installed, test it.

01. Navigate to the _test_ folder.
01. Create a new console application with `dotnet new console`, which generates a working project you can easily test with the `dotnet run` command.
1. Navigate to the _test_ folder.

1. Create a new console application with `dotnet new console`, which generates a working project you can easily test with the `dotnet run` command.

```dotnetcli
dotnet new console
Expand All @@ -211,7 +211,7 @@ Now that you have an item template installed, test it.
Restore succeeded.
```

01. Run the project using the following command.
1. Run the project using the following command.

```dotnetcli
dotnet run
Expand All @@ -223,7 +223,7 @@ Now that you have an item template installed, test it.
Hello, World!
```

01. Run `dotnet new stringext` to generate the _StringExtensions.cs_ file from the template.
1. Run `dotnet new stringext` to generate the _StringExtensions.cs_ file from the template.

```dotnetcli
dotnet new stringext
Expand All @@ -235,7 +235,7 @@ Now that you have an item template installed, test it.
The template "Example templates: string extensions" was created successfully.
```

01. Change the code in _Program.cs_ to reverse the `"Hello, World!"` string with the extension method provided by the template.
1. Change the code in _Program.cs_ to reverse the `"Hello, World!"` string with the extension method provided by the template.

```csharp
Console.WriteLine("Hello, World!".Reverse());
Expand All @@ -257,7 +257,7 @@ Congratulations! You created and deployed an item template with .NET. In prepara

## Uninstall the template

In your terminal, navigate to the _extensions_ folder and run the following command to uninstall the templates located at the current folder:
In your terminal, navigate to the _extensions_ folder and run the following command to uninstall the templates located at the current folder:

* **On Windows**: `dotnet new uninstall .\`
* **On Linux or macOS**: `dotnet new uninstall ./`
Expand Down
18 changes: 10 additions & 8 deletions docs/core/tutorials/cli-templates-create-project-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
title: Create a project template for dotnet new
description: Learn how to create a project template for the dotnet new command.
author: adegeo
ms.date: 09/08/2023
ms.date: 10/23/2025
ai-usage: ai-assisted
ms.topic: tutorial
ms.author: adegeo
---

# Tutorial: Create a project template

With .NET, you can create and deploy templates that generate projects, files, even resources. This tutorial is part two of a series that teaches you how to create, install, and uninstall, templates for use with the `dotnet new` command.
With .NET, you can create and deploy templates that generate projects, files, and resources. This tutorial is part two of a series that teaches you how to create, install, and uninstall templates for use with the `dotnet new` command.

> [!TIP]
> The official .NET templates that are shipped with the .NET SDK can be found in the following repositories:
Expand All @@ -26,7 +27,7 @@ With .NET, you can create and deploy templates that generate projects, files, ev
>
> You can view the templates that are installed on your machine by running the `dotnet new list` command.

In this part of the series you'll learn how to:
In this part of the series, you learn how to:

> [!div class="checklist"]
>
Expand All @@ -38,16 +39,17 @@ In this part of the series you'll learn how to:

## Prerequisites

* Complete [part 1](cli-templates-create-item-template.md) of this tutorial series.
* Open a terminal and navigate to the _working\content_ folder.
- [.NET 9](https://dotnet.microsoft.com/download) or a later version.

[!INCLUDE [dotnet6-syntax-note](includes/dotnet6-syntax-note.md)]
- Complete [part 1](cli-templates-create-item-template.md) of this tutorial series.

- Open a terminal and navigate to the _working\content_ folder.

## Create a project template

Project templates produce ready-to-run projects that make it easy for users to start with a working set of code. .NET includes a few project templates such as a console application or a class library. In this example, you create a new console application project that replaces the standard "Hello World" console output with one that runs asynchronously.

In your terminal, navigate to the _working\content_ folder and create a new subfolder named _consoleasync_. Enter the subfolder and run `dotnet new console` to generate the standard console application. You'll edit the files produced by this template to create a new template.
In your terminal, navigate to the _working\content_ folder and create a new subfolder named _consoleasync_. Enter the subfolder and run `dotnet new console` to generate the standard console application. Edit the files produced by this template to create a new template.

```console
working
Expand All @@ -59,7 +61,7 @@ working

## Modify Program.cs

Open up the _Program.cs_ file. The standard console project doesn't asynchronously write to the console output, so let's add that. Change the code to the following and save the file:
Open up the _Program.cs_ file. The standard console project doesn't asynchronously write to the console output, so add that. Change the code to the following and save the file:

```csharp
// See https://aka.ms/new-console-template for more information
Expand Down
23 changes: 12 additions & 11 deletions docs/core/tutorials/cli-templates-create-template-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
title: Create a template package for dotnet new
description: Learn how to create a csproj file that builds a template package for the dotnet new command.
author: adegeo
ms.date: 09/11/2023
ms.date: 10/23/2025
ai-usage: ai-assisted
ms.topic: tutorial
ms.author: adegeo
---

# Tutorial: Create a template package

With .NET, you can create and deploy templates that generate projects, files, and even resources. This tutorial is part three of a series that teaches you how to create, install, and uninstall templates for use with the `dotnet new` command.
With .NET, you can create and deploy templates that generate projects, files, and resources. This tutorial is part three of a series that teaches you how to create, install, and uninstall templates for use with the `dotnet new` command.

You can view the completed template in the [.NET Samples GitHub repository](https://github.com/dotnet/samples/tree/main/core/tutorials/cli-templates-create-item-template).

In this part of the series you'll learn how to:
In this part of the series, you learn how to:

> [!div class="checklist"]
>
Expand All @@ -23,16 +24,16 @@ In this part of the series you'll learn how to:

## Prerequisites

* Complete [part 1](cli-templates-create-item-template.md) and [part 2](cli-templates-create-project-template.md) of this tutorial series.
- [.NET 9](https://dotnet.microsoft.com/download) or a later version.

This tutorial uses the two templates created in the first two parts of this tutorial series. You can use a different template as long as you copy the template, as a folder, into the _working\content_ folder.
- Complete [part 1](cli-templates-create-item-template.md) and [part 2](cli-templates-create-project-template.md) of this tutorial series.

* Open a terminal and navigate to the _working_ folder.
This tutorial uses the two templates created in the first two parts of this tutorial series. You can use a different template as long as you copy the template, as a folder, into the _working\content_ folder.

* Install .NET 8 or .NET 9.
* Install the `Microsoft.TemplateEngine.Authoring.Templates` template from the NuGet package feed.
- Open a terminal and navigate to the _working_ folder.

* Run the `dotnet new install Microsoft.TemplateEngine.Authoring.Templates` command from your terminal.
- Install the `Microsoft.TemplateEngine.Authoring.Templates` template from the NuGet package feed.
- Run the `dotnet new install Microsoft.TemplateEngine.Authoring.Templates` command from your terminal.

## Create a template package project

Expand All @@ -42,11 +43,11 @@ Template packages are represented by a NuGet package (_.nupkg_) file. And, like

Normally you use a C# project file to compile code and produce a binary. However, the project can also be used to generate a template package. By changing the settings of the _.csproj_, you can prevent it from compiling any code and instead include all the assets of your templates as resources. When this project is built, it produces a template package NuGet package.

The package you're going to generate will include the [item](cli-templates-create-item-template.md) and [project](cli-templates-create-project-template.md) templates previously created.
The package you're going to generate includes the [item](cli-templates-create-item-template.md) and [project](cli-templates-create-project-template.md) templates previously created.

The [Microsoft.TemplateEngine.Authoring.Templates](https://www.nuget.org/packages/Microsoft.TemplateEngine.Authoring.Templates) package contains templates useful for template authoring. To install this package, nuget.org should be available as NuGet feed in the working directory.

01. In the _working_ folder, run the following command to create the template package:
1. In the _working_ folder, run the following command to create the template package:

```dotnetcli
dotnet new templatepack -n "AdatumCorporation.Utility.Templates"
Expand Down
24 changes: 8 additions & 16 deletions docs/core/tutorials/creating-app-with-plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,12 @@ static IEnumerable<ICommand> CreateCommands(Assembly assembly)
{
int count = 0;

foreach (Type type in assembly.GetTypes())
foreach (var type in assembly.GetTypes().Where(t => typeof(ICommand).IsAssignableFrom(t)))
{
if (typeof(ICommand).IsAssignableFrom(type))
if (Activator.CreateInstance(type) is ICommand result)
{
ICommand result = Activator.CreateInstance(type) as ICommand;
if (result != null)
{
count++;
yield return result;
}
count++;
yield return result;
}
}

Expand Down Expand Up @@ -194,17 +190,13 @@ Now that the `AppWithPlugin` project has the `PluginLoadContext` type, update th
static Assembly LoadPlugin(string relativePath)
{
// Navigate up to the solution root
string root = Path.GetFullPath(Path.Combine(
Path.GetDirectoryName(
Path.GetDirectoryName(
Path.GetDirectoryName(
Path.GetDirectoryName(
Path.GetDirectoryName(typeof(Program).Assembly.Location)))))));
string root = Path.GetFullPath(
Path.Combine(typeof(Program).Assembly.Location, "..", "..", "..", "..", ".."));

string pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace('\\', Path.DirectorySeparatorChar)));
Console.WriteLine($"Loading commands from: {pluginLocation}");
PluginLoadContext loadContext = new PluginLoadContext(pluginLocation);
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation)));
PluginLoadContext loadContext = new(pluginLocation);
return loadContext.LoadFromAssemblyName(new(Path.GetFileNameWithoutExtension(pluginLocation)));
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/core/tutorials/debugging-with-visual-studio-code.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
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: 09/12/2024
ms.date: 10/23/2025
---
# Tutorial: Debug a .NET console application using Visual Studio Code

This tutorial introduces the debugging tools available in Visual Studio Code for working with .NET apps.

## Prerequisites

- This tutorial works with the console app that you create in [Create a .NET console application using Visual Studio Code](with-visual-studio-code.md).
This tutorial works with the console app that you create in [Create a .NET console application using Visual Studio Code](with-visual-studio-code.md).

## Use Debug build configuration

Expand Down
7 changes: 4 additions & 3 deletions docs/core/tutorials/debugging-with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: Debug a .NET console application using Visual Studio
description: Learn how to debug a .NET console app using Visual Studio.
ms.date: 08/21/2023
ms.date: 10/23/2025
ai-usage: ai-assisted
dev_langs:
- "csharp"
- "vb"
Expand All @@ -16,15 +17,15 @@ This tutorial introduces the debugging tools available in Visual Studio.

## Prerequisites

- This tutorial works with the console app that you create in [Create a .NET console application using Visual Studio](with-visual-studio.md).
This tutorial works with the console app that you create in [Create a .NET console application using Visual Studio](with-visual-studio.md).

## Use Debug build configuration

*Debug* and *Release* are Visual Studio's built-in build configurations. You use the Debug build configuration for debugging and the Release configuration for the final release distribution.

In the Debug configuration, a program compiles with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex. The release configuration of a program has no symbolic debug information and is fully optimized.

By default, Visual Studio uses the Debug build configuration, so you don't need to change it before debugging.
By default, Visual Studio uses the Debug build configuration, so you don't need to change it before debugging.

1. Start Visual Studio.

Expand Down
3 changes: 2 additions & 1 deletion docs/core/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: .NET Tutorials
description: Follow tutorials for learning .NET to build apps and libraries on Mac, Linux, and Windows.
ms.date: 06/22/2022
ms.date: 10/23/2025
ai-usage: ai-assisted
ms.custom: devdivchpfy22
titleSuffix: ""
---
Expand Down
7 changes: 4 additions & 3 deletions docs/core/tutorials/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
title: Develop libraries with the .NET CLI
description: Learn how to create .NET libraries using the .NET CLI. You'll create a library that supports multiple frameworks.
ms.topic: how-to
ms.date: 11/23/2021
ms.date: 10/23/2025
ai-usage: ai-assisted
---
# Develop libraries with the .NET CLI

This article covers how to write libraries for .NET using the .NET CLI. The CLI provides an efficient and low-level experience that works across any supported OS. You can still build libraries with Visual Studio, and if that is your preferred experience [refer to the Visual Studio guide](library-with-visual-studio.md).
This article covers how to write libraries for .NET using the .NET CLI. The CLI provides an efficient and low-level experience that works across any supported OS. You can still build libraries with Visual Studio, and if that's your preferred experience [refer to the Visual Studio guide](library-with-visual-studio.md).

## Prerequisites

Expand All @@ -28,7 +29,7 @@ Additionally, if you wish to support older .NET Framework targets, you need to i

## How to target .NET 5+ or .NET Standard

You control your project's target framework by adding it to your project file (*.csproj* or *.fsproj*). For guidance on how to choose between targeting .NET 5+ or .NET Standard see [.NET 5+ and .NET Standard](../../standard/net-standard.md#net-5-and-net-standard).
You control your project's target framework by adding it to your project file (*.csproj* or *.fsproj*). For guidance on how to choose between targeting .NET 5+ or .NET Standard, see [.NET 5+ and .NET Standard](../../standard/net-standard.md#net-5-and-net-standard).

```xml
<Project Sdk="Microsoft.NET.Sdk">
Expand Down
5 changes: 3 additions & 2 deletions docs/core/tutorials/library-with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: Create a .NET class library using Visual Studio
description: Learn how to create a .NET class library using Visual Studio.
ms.date: 03/21/2024
ms.date: 10/23/2025
ai-usage: ai-assisted
dev_langs:
- "csharp"
- "vb"
Expand All @@ -23,7 +24,7 @@ When you create a class library, you can distribute it as a NuGet package or as

## 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 additional, related projects to the same 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.

To create the blank solution:

Expand Down
Loading