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新的网络应用程序
建立了一个 dotnet构建
使用安装的dotnet-aspnet-codegenerator
Installed dotnet-aspnet-codegenerator using
dotnet工具安装--global dotnet-aspnet-codegenerator --version 3.1.4
Ran 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
添加的包裹为:
< ItemGroup>< PackageReference Include ="Microsoft.VisualStudio.Web.CodeGeneration.Design";版本="3.1.4"./></ItemGroup>
再次运行: dotnet构建
最后一步
Ran 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核心安装版本: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
- 清除目录
- bin
- obj
dotnet aspnet-codegenerator --help
如果一切正常,它将显示可用的发电机.
If all fine it will show available generators.
这篇关于aspnet-codegenerator:即使添加了Microsoft.VisualStudio.Web.CodeGeneration.Design,也没有可用的代码生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!