Microsoft.VisualStudio.Web.CodeGeneration.Design package not being found by the dotnet aspnet-codegenerator tool
See original GitHub issueI 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:
- Created 3 years ago
- Reactions:18
- Comments:57 (9 by maintainers)
Top GitHub Comments
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.
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:
Mount it in place of your nuget directory:
Then, after running
dotnet restore
the scaffolding works as expected.