无法使用aspnet-codegenerator生成脚手架,以下是我尝试过的:
使用创建了 ASP.Net RazorPages 应用程序
dotnet new webapp
做了
dotnet build
使用
安装了 dotnet-aspnet-codegeneratordotnet 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 Core安装版本:3.1.401
操作系统:Ubuntu 20.04
从 .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 Microsoft.EntityFrameworkCore.Design
netcoreapp3.1.4
替换为 net5.0
dotnet aspnet-codegenerator --help
如果一切正常,它将显示可用的发电机。
我的案例(在 MacOS 上)的解决方案是卸载并重新安装 dotnet-aspnet-codegenerator。
在终端中运行:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
此问题的根本原因已在此问题中描述为期望不区分大小写的文件系统的 .NET 代码在 Linux 主机上失败。
建议的解决方法 是临时将您的
~/.nuget
目录挂载到 vfat 文件系统上。
为此,创建一个保存文件系统的虚拟文件
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 ...
我测试你的命令,当我这样做时
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
最新版本出现了一些问题,因此您必须通过在终端上编写以下命令来将sdk版本降级到3.1.3:
sudo apt install dotnet-sdk-3.1=3.1.301-1
之后您将需要安装以下内容:
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
之后,您需要通过在终端上写入以下内容来添加正确的 Web.CodeGeneration.Design 包:
sudo apt install dotnet-sdk-3.1=3.1.301-1
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3