You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider you have a custom .net template which has a parameter of type string. If you try and pass a value to this parameter when running dotnet new <template-name> --myParam "my-value" where that value is also one of the dotnet new commands like (search, install, list, details etc) then the dotnet cli tries to run that command instead of executing the template.
To Reproduce
Steps:
Create a new dotnet template with following folder structure and files.
Install the template by calling dotnet new install <path to your template root folder> --force
Execute the template by calling dotnet new testtemplate --name test1 --output <your-output-path> --force --customParameter "search"
You get an error with the following output as it appears that the cli is trying to execute the dotnet new search <template name> command instead.
This will also happen if you pass a string value matching any of the other dotnet new commands to the customParameter template parameter.
Unrecognized command or argument(s): 'testtemplate'.
Unrecognized command or argument(s): '--customParameter'.
Description:
Searches for the templates on NuGet.org.
Usage:
dotnet new search [<template-name>] [options]
Arguments:
<template-name> If specified, only the templates matching the name will be shown.
Options:
--author <author> Filters the templates based on the template author.
-lang, --language <language> Filters templates based on language.
--type <type> Filters templates based on available types. Predefined values are "project" and "item".
--tag <tag> Filters the templates based on the tag.
--package <package> Filters the templates based on NuGet package ID.
--columns-all Displays all columns in the output.
--columns <author|language|tags|type> Specifies the columns to display in the output.
-v, --verbosity <LEVEL> Sets the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], and diag[nostic]. [default: normal]
-d, --diagnostics Enables diagnostic output.
-?, -h, --help Show command line help.
Interestingly, if you execute dotnet new create <template name> instead then everything seems to work correctly and the template is executed. e.g. dotnet new create testtemplate --name test1 --output <your-output-path> --force --customParameter "search"
The text was updated successfully, but these errors were encountered:
asos-lewish
changed the title
Passing a value to a template parameter which is one of the dotnet new commands causes the cli to try and run that command
Passing a value to a template parameter that is one of the dotnet new commands causes the cli to try and run that command
Nov 21, 2024
asos-lewish
changed the title
Passing a value to a template parameter that is one of the dotnet new commands causes the cli to try and run that command
Passing a value to a template parameter that is one of the dotnet new commands causes the cli to try and run that command instead
Nov 21, 2024
Product
dotnet CLI (dotnet new)
Describe The Bug
Consider you have a custom .net template which has a parameter of type string. If you try and pass a value to this parameter when running
dotnet new <template-name>
--myParam "my-value" where that value is also one of the dotnet new commands like (search, install, list, details etc) then the dotnet cli tries to run that command instead of executing the template.To Reproduce
Steps:
template.json
file under.template.config
folder.Install the template by calling
dotnet new install <path to your template root folder> --force
Execute the template by calling
dotnet new testtemplate --name test1 --output <your-output-path> --force --customParameter "search"
You get an error with the following output as it appears that the cli is trying to execute the
dotnet new search <template name>
command instead.This will also happen if you pass a string value matching any of the other
dotnet new
commands to the customParameter template parameter.dotnet Info
output
.NET SDK: Version: 8.0.202 Commit: 25674bb2f4 Workload version: 8.0.200-manifests.4e94be9cRuntime Environment:
OS Name: Mac OS X
OS Version: 14.7
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.202/
.NET workloads installed:
There are no installed workloads to display.
Host:
Version: 8.0.3
Architecture: arm64
Commit: 9f4b1f5d66
.NET SDKs installed:
7.0.408 [/usr/local/share/dotnet/sdk]
8.0.202 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.29 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/usr/local/share/dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Visual Studio Version
No response
Additional context
Interestingly, if you execute
dotnet new create <template name>
instead then everything seems to work correctly and the template is executed. e.g.dotnet new create testtemplate --name test1 --output <your-output-path> --force --customParameter "search"
The text was updated successfully, but these errors were encountered: