question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft.VisualStudio.Web.CodeGeneration.Design package not being found by the dotnet aspnet-codegenerator tool

See original GitHub issue

I just created an MVC app with dotnet new mvc --name test-project (netcoreapp3.1), without any kind of database access and Identity, which I would like to add by hand for customisation purposes. Then I added some packages in order to use the dotnet aspnet-codegenerator tool. My .csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>test_project</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.7">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.7">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
  </ItemGroup>
</Project>

As you can see, the Microsoft.VisualStudio.Web.CodeGeneration.Design is the first in the list. However, when I try to run any scaffolder from the dotnet aspnet-codegenerator tool (e.g.: dotnet aspnet-codegenerator identity -h), I get the following message:

No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.

Even if I specify the .csproj file with the -p flag, I still get the same message. While doing some research, I found this Issue in the repo, but it’s a different thing: the OP was trying to add the scaffolder to a .NET Core App 3.0 using the 3.1 scaffolder version.

I’m using dotnet 3.1.401 on Xubuntu 20.04.

Any thoughts? Thank you in advance.

Steps to reproduce:

  • Install latest dotnet through MS repos
  • dotnet tool install dotnet-aspnet-codegenerator --version 3.1.4
  • dotnet new mvc
  • dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design -v 3.1.4 && dotnet restore && dotnet build
  • dotnet aspnet-codegenerator identity -h

Expected behaviour:

  • The Scaffolding tool should at least show any helpful information about the scaffolder

Actual behaviour:

  • It shows the following message, even after adding the referred NuGet Package to the project: No code generators are available in this project. Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.

Additional information about the project being scaffolded, such as:

Target framework(s): netcoreapp3.1

Package version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All (if applicable):

Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding: 3.1.4, actually this problem can be reproduced even with the 3.1.3 version of it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:18
  • Comments:57 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
deepchoudherycommented, Feb 11, 2021

Hey all, @rhaynes123 @jonathan-daniel @cezarlamann @sanjitn @mtausig @MadeleineRoberts-WellSky @gustavohrgomes @stephen-innotek @lctx @iBolski @KilianKilmister @NorbiPeti

I have a fix for this issue out with a new 3.1.5 and 5.0.2 package out. Use dotnet tool update dotnet-aspnet-codegenerator -g --version 3.1.5/5.0.2 depending on if you are targeting .netcoreapp3.1 or net5.0. I would like it if someone could confirm the fix before I close the issue.

You will also need to update the Microsoft.VisualStudio.Web.CodeGeneration.Design package as well.

Apologize for the lengthy delay on this fix and appreciate all the feedback.

10reactions
mtausigcommented, Dec 29, 2020

Since @mwdmwd was able to find the root cause for the problem, I was successful with the following workaround (using Ubuntu 18.04 and .NET 5.0):

Create a dummy vfat filesystem:

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

Mount it in place of your nuget directory:

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

Then, after running dotnet restore the scaffolding works as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.VisualStudio.Web.CodeGeneration.Design not ...
I uninstalled and reinstalled Microsoft.VisualStudio.Web.CodeGeneration.Design NuGet package in the project's package manager.
Read more >
Install-Package Microsoft.VisualStudio.Web. ...
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design renders following error message: PM> install-package microsoft.VisualStudio ...
Read more >
Microsoft.VisualStudio.Web.CodeGeneration.Design 7.0.9
Version Downloads Last updated 8.0.0‑preview.7.23408.2 887 6 days ago 8.0.0‑preview.6.23360.4 4,597 a month ago 8.0.0‑preview.5.23313.2 4,249 2 months ago
Read more >
Microsoft.VisualStudio.Web.CodeGeneration.Utils not ...
When attempting to add a blank API controller to an ASP.NET Core Razor Pages project via the scaffolding option on VS Mac 8.5.3/16,...
Read more >
ASP.NET Scaffolding Tell Users About Additional NuGet ...
Checking 'Microsoft.EntityFrameworkCore.Tools' NuGet Package... Checking 'Microsoft.VisualStudio.Web.CodeGeneration.Design' NuGet Package... Kotlin detected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found