Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design

Unable to generate scaffolding using aspnet-codegenerator, below is what I tried:

  1. Created an ASP.Net RazorPages application using dotnet new webapp

  2. Did a dotnet build

  3. Installed dotnet-aspnet-codegenerator using

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

  4. Ran dotnet aspnet-codegenerator --help

    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.

  5. Added the package mentioned in step 4 using

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

    Package added is:

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

  6. Again ran: dotnet build

    Final-Step

  7. Ran dotnet aspnet-codegenerator --help

    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 core installed version: 3.1.401

Os: Ubuntu 20.04

like image 354
Gurdeep Singh Sidhu Avatar asked Aug 25 '20 17:08

Gurdeep Singh Sidhu


People also ask

What is Microsoft Visualstudio Web CodeGeneration design used for?

CodeGeneration. Design. Code Generation tool for ASP.NET Core. Contains the dotnet-aspnet-codegenerator command used for generating controllers and views.

What is Aspnet Codegenerator?

dotnet-aspnet-codegenerator - Runs the ASP.NET Core scaffolding engine. dotnet-aspnet-codegenerator is only required to scaffold from the command line, it's not needed to use scaffolding with Visual Studio.


3 Answers

I have same problem when upgrade from .net core 3.1.4 to 5.0.1.

My solution:

  1. update global tools:
  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. add/update links to packages
  dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
  dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
  dotnet add package Microsoft.EntityFrameworkCore.Design
  1. Replace string netcoreapp3.1.4 to net5.0 in .csproj and launch.json files
  2. Clear directories
    • bin
    • obj
  3. Rebuild project
  4. Finally run:
  dotnet aspnet-codegenerator --help

If all fine it will show available generators.

like image 175
Roman Z Avatar answered Oct 30 '22 04:10

Roman Z


This is already a few month old, but I ran into it recently for all my projects.

In case someone else lands on this page, the solution in my case(MAC OS), was to uninstall and reinstall dotnet-aspnet-codegenerator.

Run in terminal:

dotnet tool uninstall --global dotnet-aspnet-codegenerator

dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
like image 28
Blondu Avatar answered Oct 30 '22 05:10

Blondu


The root cause of this problem has been described in this issue as the .NET code expecting a case-insensitive filesystem which fails on a Linux host.

A suggested workaround would be to temporarily mount you ~/.nuget directory on a vfat filesystem.

To do so create a dummy file holding the filesystem

dd if=/dev/zero of=/tmp/mynuget bs=1024k count=2000
mkfs.vfat /tmp/mynuget

and then mount it

sudo mount -o uid=myuser,gid=myuser -t vfat /tmp/mynuget /home/myuser/.nuget

and use it

dotnet restore
dotnet aspnet-codegenerator ...
like image 36
mat Avatar answered Oct 30 '22 04:10

mat