Skip to content

dotnet new article - updates for 5.0.3xx SDK #23875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 25, 2021
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
4 changes: 2 additions & 2 deletions docs/core/testing/unit-testing-code-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The "system under test" refers to the code that you're writing unit tests agains

### Create a class library

From a command prompt in a new directory named `UnitTestingCodeCoverage`, create a new .NET standard class library using the [`dotnet new classlib`](../tools/dotnet-new.md#classlib) command:
From a command prompt in a new directory named `UnitTestingCodeCoverage`, create a new .NET standard class library using the [`dotnet new classlib`](../tools/dotnet-new-sdk-templates.md#classlib) command:

```dotnetcli
dotnet new classlib -n Numbers
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace System.Numbers

### Create test projects

Create two new **xUnit Test Project (.NET Core)** templates from the same command prompt using the [`dotnet new xunit`](../tools/dotnet-new.md#test) command:
Create two new **xUnit Test Project (.NET Core)** templates from the same command prompt using the [`dotnet new xunit`](../tools/dotnet-new-sdk-templates.md#test) command:

```dotnetcli
dotnet new xunit -n XUnit.Coverlet.Collector
Expand Down
62 changes: 62 additions & 0 deletions docs/core/tools/dotnet-new-install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: dotnet new --install option
description: The dotnet new --install option installs a template package.
ms.date: 04/29/2021
---
# dotnet new --install option

**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions

## Name

`dotnet new --install` - installs a template package.

## Synopsis

```dotnetcli
dotnet new --install <PATH|NUGET_ID> [--interactive] [--nuget-source <SOURCE>]
```

## Description

The `dotnet new --install` command installs a template package from the `PATH` or `NUGET_ID` provided. If you want to install a prerelease version of a template package, specify the version in the format `<package-name>::<package-version>`. By default, `dotnet new` passes \* for the version, which represents the latest stable package version. For more information, see the [Examples](#examples) section.

If a version of the template was already installed when you run this command, the template will be updated to the specified version, or to the latest stable version if no version was specified.
For information on creating custom templates, see [Custom templates for dotnet new](custom-templates.md).

## Options

- **`--interactive`**

Allows the command to stop and wait for user input or action (for example to complete authentication). Available since .NET Core 5.0 SDK.

- **`--nuget-source <SOURCE>`**

By default, `dotnet new --install` uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If `--nuget-source` is specified, the source will be added to the list of sources to be checked.
To check the configured sources for the current directory use [`dotnet nuget list source`](dotnet-nuget-list-source.md). For more information, see [Common NuGet Configurations](/nuget/consume-packages/configuring-nuget-behavior)

## Examples

- Install the latest version of SPA templates for ASP.NET Core:

```dotnetcli
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates
```

- Install version 2.0 of the SPA templates for ASP.NET Core:

```dotnetcli
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0
```

- Install version 2.0 of the SPA templates for ASP.NET Core from a custom NuGet source using interactive mode:

```dotnetcli
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0 --nuget-source "https://api.my-custom-nuget.com/v3/index.json" --interactive
```

## See also

- [dotnet new command](dotnet-new.md)
- [dotnet new --search option](dotnet-new-search.md)
- [Custom templates for dotnet new](custom-templates.md)
109 changes: 109 additions & 0 deletions docs/core/tools/dotnet-new-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: dotnet new --list option
description: The dotnet new --list option lists available templates.
ms.date: 04/29/2021
---
# dotnet new --list option

**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**This article applies to:** ✔️ .NET Core 2.0 SDK and later versions
**This article applies to:** ✔️ .NET 5.0.300 SDK and later versions

Copy link
Member Author

Choose a reason for hiding this comment

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

--list option exists from .NET Core 2.0 SDK. Only few options were added in 5.0.3xx (--author, --tag, --columns, --columns-all).


## Name

`dotnet new --list` - Lists available templates to be run using `dotnet new`.

## Synopsis

```dotnetcli
dotnet new [<TEMPLATE_NAME>] -l|--list [--author <AUTHOR>] [-lang|--language {"C#"|"F#"|VB}]
[--tag <TAG>] [--type <TYPE>] [--columns <COLUMNS>] [--columns-all]
```

## Description

The `dotnet new --list` option lists available templates to use with `dotnet new`. If the <TEMPLATE_NAME> is specified, lists templates containing the specified name. This option lists only default and installed templates. To find templates in NuGet that you can install locally, use the [`--search`](dotnet-new-search.md) option.

## Arguments

- **`TEMPLATE_NAME`**

If the argument is specified, only the templates containing `<TEMPLATE_NAME>` in template name or short name will be shown.

## Options

- **`--author <AUTHOR>`**

Filters templates based on template author. Partial match is supported. Available since .NET Core 5.0.300 SDK.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Filters templates based on template author. Partial match is supported. Available since .NET Core 5.0.300 SDK.
Filters templates based on template author. Partial match is supported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends on outcome in #23875 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

You're correct, ignore this suggestion and the others like it in this article.


- **`--columns <COLUMNS>`**

Comma-separated list of columns to display in the output. The supported columns are:
- `language` - A comma-separated list of languages supported by the template.
- `tags` - The list of template tags.
- `author` - The template author.
- `type` - The template type: project or item.

The template name and short name are always shown. The default list of columns is template name, short name, language, and tags. This list is equivalent to specifying `--columns=language,tags`.
Available since .NET Core 5.0.300 SDK.

- **`--columns-all`**

Displays all columns in the output. Available since .NET Core 5.0.300 SDK.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Displays all columns in the output. Available since .NET Core 5.0.300 SDK.
Displays all columns in the output.

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends on outcome in #23875 (comment)


- **`-lang|--language {C#|F#|VB}`**

Filters templates based on language supported by the template. The language accepted varies by the template. Not valid for some templates.

> [!NOTE]
> Some shells interpret `#` as a special character. In those cases, enclose the language parameter value in quotes. For example, `dotnet new --list --language "F#"`.

- **`--tag <TAG>`**

Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria. Available since .NET Core 5.0.300 SDK.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria. Available since .NET Core 5.0.300 SDK.
Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria.

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends on outcome in #23875 (comment)


- **`--type <TYPE>`**

Filters templates based on template type. Predefined values are `project` and `item`.

Choose a reason for hiding this comment

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

nit: Should we take this opportunity to include "solution"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like we should also explain the difference between types when adding "solution" in https://docs.microsoft.com/en-us/dotnet/core/tools/custom-templates.
dotnet new doesn't care about types except filtering here, whereas Visual Studio does. We probably should explain in mentioned article both type and language, and supported values for type given their purpose in Visual Studio. We have dotnet/templating#2833 for it, I suggest to address it later.


## Examples

- List all templates

```dotnetcli
dotnet new --list
```

- List all Single Page Application (SPA) templates:

```dotnetcli
dotnet new spa --list
```

- List all templates matching the *we* substring.

```dotnetcli
dotnet new we --list
```

- List all templates matching the *we* substring that support the F# language.

```dotnetcli
dotnet new we --list --language "F#"
```

- List all item templates.

```dotnetcli
dotnet new --list --type item
```

- List all C# templates, showing the author and the type in the output.

```dotnetcli
dotnet new --list --language "C#" --columns "author,type"
```

## See also

- [dotnet new command](dotnet-new.md)
- [dotnet new --search option](dotnet-new-search.md)
- [Custom templates for dotnet new](custom-templates.md)
Loading