我试图弄清楚dotnet核心是如何工作的,因此创建了一些项目来解决它。我找到了一个指南,他们说,我应该运行" dotnet new -t web"创建功能更全面的Web应用程序。但是,当我这样做时,它只是说:
Invalid input switch:
-t
Template Instantiation Commands for .NET Core CLI.
Usage: dotnet new [arguments] [options]
Arguments:
template The template to instantiate.
他们改变了吗?为什么当我运行" dotnet new"时,没有任何文件出现,但只有当我做了#34; dotnet new mvc"或者" dotnet new web"。我正在使用Visual Studio Code。
提前致谢。
答案 0 :(得分:5)
是的,他们更改了CLI工具,作为从project.json
迁回csproj
的一部分。关于官方documents的更多信息。
最佳来源是dotnet new
的最新文档:
根据指定的模板创建新项目,配置文件或解决方案。
dotnet new <TEMPLATE> [-lang|--language] [-n|--name] [-o|--output] [-all|--show-all] [-h|--help] [Template arguments] dotnet new <TEMPLATE> [-l|--list] dotnet new [-all|--show-all] dotnet new [-h|--help]
示例:
dotnet new mvc ==> New C# MVC app dotnet new console -lang f# ==> New F# console app
答案 1 :(得分:0)
您所关注的指南看起来像是引用了之前版本的dotnet core cli。在以前的版本中,-t
需要指定模板。现在它的工作方式不同了。
根据documentation,您可以通过以下方式之一使用命令new
:
dotnet new <TEMPLATE> [-lang|--language] [-n|--name] [-o|--output] [-all|--show-all] [-h|--help] [Template arguments]
dotnet new <TEMPLATE> [-l|--list]
dotnet new [-all|--show-all]
dotnet new [-h|--help]
但是,即使您致电dotnet new
,它也应显示一些信息(在VS Code和命令行中检查)。
希望这会有所帮助。