10

无法使用aspnet-codegenerator生成脚手架,下面是我尝试过的:

  1. 使用创建了一个 ASP.Net RazorPages 应用程序 dotnet new webapp

  2. 做了一个dotnet build

  3. 使用安装 dotnet-aspnet-codegenerator

    dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4

  4. dotnet aspnet-codegenerator --help

    它说:此项目中没有可用的代码生成器。将Microsoft.VisualStudio.Web.CodeGeneration.Design包作为 NuGet 包引用添加到项目中。

  5. 使用添加了步骤 4 中提到的包

    dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design

    添加的包是:

    <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" /> </ItemGroup>

  6. 又跑了:dotnet build

    最后一步

  7. dotnet aspnet-codegenerator --help

    它再次表示:此项目中没有可用的代码生成器。将 Microsoft.VisualStudio.Web.CodeGeneration.Design 包作为 NuGet 包引用添加到项目中。

.Net核心安装版本:3.1.401

操作系统:Ubuntu 20.04

4

5 回答 5

6

从 .net core 3.1.4 升级到 5.0.1 时我遇到了同样的问题。

我的解决方案:

  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
  1. 添加/更新包的链接
  dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
  dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
  dotnet add package Microsoft.EntityFrameworkCore.Design
  1. 将字符串替换netcoreapp3.1.4net5.0.csproj 和 launch.json 文件
  2. 清除目录
    • 垃圾桶
    • 对象
  3. 重建项目
  4. 最后运行:
  dotnet aspnet-codegenerator --help

如果一切正常,它将显示可用的生成器。

于 2020-12-15T12:31:53.623 回答
4

这已经有几个月了,但我最近在我的所有项目中都遇到了它。

如果其他人登陆此页面,我的解决方案(MAC OS)是卸载并重新安装 dotnet-aspnet-codegenerator。

在终端中运行:

dotnet tool uninstall --global dotnet-aspnet-codegenerator

dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
于 2020-11-21T07:33:56.760 回答
2

此问题的根本原因已在此问题中描述为 .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 ...
于 2020-12-29T11:31:51.913 回答
0

我找到了这个问题的解决方案:

最新版本存在一些问题,因此您必须通过在终端上编写以下命令将 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

这对我有用!

于 2020-12-04T03:34:14.107 回答
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
于 2020-08-26T06:10:28.937 回答