我无法尝试使用 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
答案 0 :(得分:2)
此问题的根本原因已在 this issue 中描述为 .NET 代码期望不区分大小写的文件系统在 Linux 主机上失败。
suggested workaround 将临时挂载您在 vfat 文件系统上的 ~/.nuget
目录。
为此创建一个包含文件系统的虚拟文件
dd if=/dev/zero of=/tmp/mynuget bs=1024k count=2000
mkfs.vfat /tmp/mynuget
然后挂载
sudo mount -o uid=myuser,gid=myuser -t vfat /tmp/mynuget /home/myuser/.nuget
并使用它
dotnet restore
dotnet aspnet-codegenerator ...
答案 1 :(得分:1)
这已经有几个月的历史了,但是最近我所有的项目都碰到了它。
如果其他人登陆此页面,在我的案例中(MAC OS),解决方案是卸载并重新安装dotnet-aspnet-codegenerator。
在终端中运行:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
答案 2 :(得分:0)
我测试了您的命令,当我执行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
答案 3 :(得分:0)
我找到了此问题的解决方案:
最新版本存在一些问题,因此您必须通过在终端上编写以下命令,将sdk的版本降级为3.1.3 :
sudo apt install dotnet-sdk-3.1 = 3.1.301-1
之后,您需要安装以下内容:
dotnet工具安装--global dotnet-aspnet-codegenerator --version 3.1.3
之后,您需要通过在终端上编写以下代码来添加正确的Web.CodeGeneration.Design程序包:
sudo apt安装dotnet-sdk-3.1 = 3.1.301-1 dotnet工具安装--global dotnet-aspnet-codegenerator --version 3.1.3
那对我有用!
答案 4 :(得分:0)
从.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
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Add package Microsoft.EntityFrameworkCore.Design
netcoreapp3.1.4
替换为net5.0
dotnet aspnet-codegenerator --help
如果一切正常,它将显示可用的发电机。