Asp.net 创建新项目时,如何更改dotnet新模板的名称?
我已经创建了一个Asp.net 创建新项目时,如何更改dotnet新模板的名称?,asp.net,.net,visual-studio,.net-core,Asp.net,.net,Visual Studio,.net Core,我已经创建了一个dotnet模板,用于dotnet new。从该模板创建新项目时,它可以正常工作,但是程序集和命名空间名称仍然是“模板”,而不是新项目 我尝试创建一个新项目,并使用--name标志和--output标志手动设置名称,但没有效果 我想我可以在某处使用一个变量,也许在template.json文件中 谢谢,您必须设置模板,然后使用选项参数,如-n参数并给出名称。 比如说, dotnet new web -n myBestName 您可以查看有关cli的更多信息 source您需要在
dotnet
模板,用于dotnet new
。从该模板创建新项目时,它可以正常工作,但是程序集和命名空间名称仍然是“模板”,而不是新项目
我尝试创建一个新项目,并使用--name
标志和--output
标志手动设置名称,但没有效果
我想我可以在某处使用一个变量,也许在template.json文件中
谢谢,您必须设置模板,然后使用选项参数,如-n参数并给出名称。 比如说,
dotnet new web -n myBestName
您可以查看有关cli的更多信息
source您需要在
template.json
文件中设置sourceName
您可以参考本页了解每个字段的用途
"sourceName": {
"description": "The name in the source tree to replace with the name the user specifies",
"type": "string"
},
template.json
文件的一个基本示例如下所示。注意sourceName
{
"$schema": "http://json.schemastore.org/template",
"author": "Me",
"classifications": [ "web api", "asp.net core", "C#" ],
"identity": "WebApi.Template",
"name": "WebApi.Template",
"shortName": "WebApiTemplate",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "WebApi.Template",
"preferNameDirectory" : true
}
如果使用与上述类似的template.json
,则可以在cli命令中使用dotnet new YourTemplateName-n yourtcomponentname
或仅在使用组件名称命名的文件夹中运行dotnet new YourTemplateName