Gur*_*dhu 9 asp.net-core-mvc .net-core asp.net-core razor-pages asp.net-core-razor-pages
无法使用aspnet-codegenerator生成脚手架,下面是我尝试过的:
使用创建了一个 ASP.Net RazorPages 应用程序
dotnet new webapp
做了一个 dotnet build
安装 dotnet-aspnet-codegenerator 使用
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
冉 dotnet aspnet-codegenerator --help
它说:此项目中没有可用的代码生成器。将Microsoft.VisualStudio.Web.CodeGeneration.Design包作为 NuGet 包引用添加到项目中。
使用添加了步骤 4 中提到的包
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
添加的包是:
<ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" /> </ItemGroup>
再次运行: dotnet build
最后一步
冉 dotnet aspnet-codegenerator --help
再次显示:此项目中没有可用的代码生成器。将 Microsoft.VisualStudio.Web.CodeGeneration.Design 包作为 NuGet 包引用添加到项目中。
.Net核心安装版本:3.1.401
操作系统:Ubuntu 20.04
小智 6
我的案例(在 MacOS 上)的解决方案是卸载并重新安装 dotnet-aspnet-codegenerator。
在终端中运行:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
Run Code Online (Sandbox Code Playgroud)
小智 5
从 .net core 3.1.4 升级到 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
Run Code Online (Sandbox Code Playgroud)
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
Run Code Online (Sandbox Code Playgroud)
netcoreapp3.1.4为net5.0.csproj 和 launch.json 文件 dotnet aspnet-codegenerator --help
Run Code Online (Sandbox Code Playgroud)
如果一切正常,它将显示可用的发电机。
我测试你的命令,当我这样做时dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4,我可以得到

然后Ran dotnet aspnet-codegenerator --help,我收到与您相同的消息 No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet,但是当我执行以下操作时,我可以在没有消息的情况下运行:

我认为可能是该包没有正确添加,您可以尝试删除并重新添加。
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2254 次 |
| 最近记录: |