如何解决Razor Page脚手架:找不到名称为“ razorpage”的代码生成器
我正在尝试在Razor Pages项目中为新页面添加脚手架。但是,我在ASP.NET Core Scaffolder中始终得到以下输出:
Checking if needed NuGet packages are already installed…
Building project…
Running /Users/lukeengland/Projects/AssetManager2/AssetManager2/obj/dotnet-aspnet-codegenerator --configuration "Debug" --project "/Users/lukeengland/Projects/AssetManager2/AssetManager2/AssetManager2.csproj" razorpage --model User --dataContext NewUserContext --referenceScriptLibraries --useDefaultLayout --no-build -outDir "/Users/lukeengland/Projects/AssetManager2/AssetManager2/Pages/Users2" --namespaceName AssetManager2.Pages.Users2 --useSqlite
Finding the generator 'razorpage'...
No code generators found with the name 'razorpage'
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.GetCodeGenerator(String codeGeneratorName)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:03.28
No code generators found with the name 'razorpage'
当尝试使用我的项目中的任何模型创建脚手架时,就会发生这种情况。几周前,我能够为某些页面创建脚手架,所以不确定此后发生了什么变化。任何建议都非常感谢
PS:我正在Mac上使用Microsoft Visual Studio 2019
解决方法
我在VS Mac和'dotnet-aspnet-codegenerator'和'Microsoft.VisualStudio.Web.CodeGeneration.Design'版本上出现完全相同的错误。代替使用VS向导,使用dotnet CLI似乎可以解决并创建所有脚手架文件,但是需要查看它是否确实有效。.仍在学习:)
请尝试:
dotnet aspnet-codegenerator --configuration "Debug" --project "/Users/lukeengland/Projects/AssetManager2/AssetManager2/AssetManager2.csproj" razorpage --model User --dataContext NewUserContext --referenceScriptLibraries --useDefaultLayout --no-build -outDir "/Users/lukeengland/Projects/AssetManager2/AssetManager2/Pages/Users2" --namespaceName AssetManager2.Pages.Users2 --useSqlite
,
在使用CLI脚手架工具的Ubuntu上,我遇到了同样的问题。对我来说,解决方法是将SDK(和)降级为3.1.301
版本,如本github comment所述:
sudo apt install dotnet-sdk-3.1=3.1.301-1
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
,
当尝试使用Visual Studio for Mac和最新.NET 5创建剃须刀页面EF支架时,发生了同样的问题。
Finding the generator 'razorpage'...
No code generators found with the name 'razorpage'
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.GetCodeGenerator(String codeGeneratorName)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:03.76
No code generators found with the name 'razorpage'
我能够通过运行dotnet CLI来创建支架
dotnet aspnet-codegenerator --configuration "Debug" --project "/Users/Max/Repos/VSProjects/WebApplication/WebApplication/WebApplication.csproj" razorpage --model Movie --dataContext WebApplication.Data.WebApplicationContext --referenceScriptLibraries --useDefaultLayout --no-build -outDir "/Users/Max/Repos/VSProjects/WebApplication/WebApplication/Models" --namespaceName WebApplication.Models --useSqlite
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。