aspnet-codegenerator:没有可用的代码生成器,即使在添加 Microsoft.VisualStudio.Web.CodeGeneration.Design 之后 [英] aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design
问题描述
无法使用 aspnet-codegenerator 生成脚手架,以下是我尝试过的:
Unable to generate scaffolding using aspnet-codegenerator, below is what I tried:
使用创建了一个 ASP.Net RazorPages 应用程序
dotnet new webapp
做了一个 dotnet 构建
使用
dotnet 工具安装 --global dotnet-aspnet-codegenerator --version 3.1.4
跑 dotnet aspnet-codegenerator --help
它说:此项目中没有可用的代码生成器.将 Microsoft.VisualStudio.Web.CodeGeneration.Design 包作为 NuGet 包引用添加到项目中.
It says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
使用
dotnet 添加包 Microsoft.VisualStudio.Web.CodeGeneration.Design
添加的包是:
<代码><项目组><PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design";版本=3.1.4"/></项目组>
再次运行:dotnet build
最后一步
跑 dotnet aspnet-codegenerator --help
再次它说:此项目中没有可用的代码生成器.将 Microsoft.VisualStudio.Web.CodeGeneration.Design 包作为 NuGet 包引用添加到项目中.
Again it says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
.Net core 安装版本:3.1.401
.Net core installed version: 3.1.401
操作系统:Ubuntu 20.04
Os: Ubuntu 20.04
推荐答案
我在从 .net core 3.1.4 升级到 5.0.1 时遇到同样的问题.
I have same problem when upgrade from .net core 3.1.4 to 5.0.1.
我的解决方案:
- 更新全局工具:
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet tool update --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-ef
dotnet tool update --global dotnet-ef
- 添加/更新包的链接
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
- 将 .csproj 和 launch.json 文件中的字符串
netcoreapp3.1.4
替换为net5.0
- 清除目录
- 斌
- 对象
dotnet aspnet-codegenerator --help
如果一切正常,它将显示可用的生成器.
If all fine it will show available generators.
这篇关于aspnet-codegenerator:没有可用的代码生成器,即使在添加 Microsoft.VisualStudio.Web.CodeGeneration.Design 之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!