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

杀马特。学长 韩版系。学妹 提交于 2020-12-06 05:02:47

问题


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 on their 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.

EDIT 1 Some people suggested this would be close to what we have here, but the thing is: I know what it does and I actually added the "global tools" suggested in that article. The problem is the aspnet-codegenerator is not detecting that I already have the library it needs to its things, added to the .csproj file.

EDIT 1

Apparently, there's a couple of people facing this issue as well, so, I filed an issue on their repo


回答1:


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

Related topic here



来源:https://stackoverflow.com/questions/63440962/microsoft-visualstudio-web-codegeneration-design-not-being-found-by-the-dotnet-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!