Skip to content
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

How to create projects that target earlier frameworks #25603

Merged
merged 4 commits into from
Aug 18, 2021
Merged
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
28 changes: 27 additions & 1 deletion docs/core/tools/dotnet-new-sdk-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: .NET default templates for dotnet new
description: The information about dotnet new templates shipped with dotnet SDK.
no-loc: [Blazor, WebAssembly]
ms.date: 04/29/2021
ms.date: 08/18/2021
---
# .NET default templates for dotnet new

Expand Down Expand Up @@ -70,6 +70,10 @@ Each template may have additional options available. The core templates have the
| 3.1 | `netcoreapp3.1` |
| 3.0 | `netcoreapp3.0` |

The ability to create a project for an earlier TFM depends on having that version of the SDK installed. For example, if you have only SDK 5.0 installed, then the only value available for `--framework` is `net5.0`. If you install SDK 3.1, the value `netcoreapp3.1` becomes available for `--framework`. If you install SDK 2.1, `netcoreapp2.1` becomes available, and so on. So by specifying `--framework netcoreapp2.1` you can use SDK 2.1 even while running `dotnet new` in SDK 5.0.

Alternatively, to create a project that targets a framework earlier than the SDK that you're using, you might be able to do it by installing the NuGet package for the template. [Common](https://www.nuget.org/packages?q=Microsoft.DotNet.Common.ProjectTemplates), [web](https://www.nuget.org/packages?q=Microsoft.DotNet.Web.ProjectTemplates), and [SPA](https://www.nuget.org/packages?q=Microsoft.DotNet.Web.Spa.ProjectTemplates) project types use different packages per target framework moniker (TFM). For example, to create a `console` project that targets `netcoreapp1.0`, run [`dotnet new --install`](dotnet-new-install.md) on `Microsoft.DotNet.Common.ProjectTemplates.1.x`.

- **`--langVersion <VERSION_NUMBER>`**

Sets the `LangVersion` property in the created project file. For example, use `--langVersion 7.3` to use C# 7.3. Not supported for F#. Available since .NET Core 2.2 SDK.
Expand All @@ -88,6 +92,8 @@ Each template may have additional options available. The core templates have the

Specifies the [framework](../../standard/frameworks.md) to target. Values: `net5.0` or `netcoreapp<version>` to create a .NET Class Library or `netstandard<version>` to create a .NET Standard Class Library. The default value for .NET 5.0 SDK is `net5.0`.

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--langVersion <VERSION_NUMBER>`**

Sets the `LangVersion` property in the created project file. For example, use `--langVersion 7.3` to use C# 7.3. Not supported for F#. Available since .NET Core 2.2 SDK.
Copy link
Member

Choose a reason for hiding this comment

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

Not related to your PR, but we should make an explicit statement about VB support for --langVersion.

Expand All @@ -106,6 +112,8 @@ Each template may have additional options available. The core templates have the

Specifies the [framework](../../standard/frameworks.md) to target. The default value is `net5.0`. Available since .NET Core 3.1 SDK.

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--langVersion <VERSION_NUMBER>`**

Sets the `LangVersion` property in the created project file. For example, use `--langVersion 7.3` to use C# 7.3.
Expand Down Expand Up @@ -138,6 +146,8 @@ Each template may have additional options available. The core templates have the

Specifies the [framework](../../standard/frameworks.md) to target. The default value is `netcoreapp3.1`. Available since .NET Core 3.1 SDK.

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--exclude-launch-settings`**

Excludes *launchSettings.json* from the generated template.
Expand All @@ -162,6 +172,8 @@ Each template may have additional options available. The core templates have the
| 3.1 | `netcoreapp3.1` |
| 3.0 | `netcoreapp3.0` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`-p|--enable-pack`**

Enables packaging for the project using [dotnet pack](dotnet-pack.md).
Expand All @@ -188,6 +200,8 @@ Each template may have additional options available. The core templates have the
| 2.2 | `netcoreapp2.2` |
| 2.1 | `netcoreapp2.1` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`-p|--enable-pack`**

Enables packaging for the project using [dotnet pack](dotnet-pack.md).
Expand Down Expand Up @@ -302,6 +316,8 @@ Each template may have additional options available. The core templates have the
| 5.0 | `net5.0` |
| 3.1 | `netcoreapp3.1` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.
Expand Down Expand Up @@ -412,6 +428,8 @@ Each template may have additional options available. The core templates have the
| 3.0 | `netcoreapp3.0` |
| 2.1 | `netcoreapp2.1` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.
Expand Down Expand Up @@ -499,6 +517,8 @@ Each template may have additional options available. The core templates have the
| 3.1 | `netcoreapp3.1` |
| 3.0 | `netcoreapp3.0` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.
Expand Down Expand Up @@ -553,6 +573,8 @@ Each template may have additional options available. The core templates have the
| 3.0 | `netcoreapp3.0` |
| 2.1 | `netcoreapp2.0` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

***

## `reactredux`
Expand All @@ -574,6 +596,8 @@ Each template may have additional options available. The core templates have the
| 3.0 | `netcoreapp3.0` |
| 2.1 | `netcoreapp2.0` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.
Expand Down Expand Up @@ -660,6 +684,8 @@ Each template may have additional options available. The core templates have the
| 3.0 | `netcoreapp3.0` |
| 2.1 | `netcoreapp2.1` |

To create a project that targets a framework earlier than the SDK that you're using, see [`--framework` for `console` projects](#template-options) earlier in this article.

- **`--no-restore`**

Doesn't execute an implicit restore during project creation.
Expand Down