dotnet aspnet代码生成器工具找不到Microsoft.VisualStudio.Web.CodeGeneration.Design [英] Microsoft.VisualStudio.Web.CodeGeneration.Design not being found by the dotnet aspnet-codegenerator tool
问题描述
我刚刚使用 dotnet new mvc --name test-project
( netcoreapp3.1
)创建了一个MVC应用程序,没有任何数据库访问权限和身份,想要手动添加以进行自定义.然后,我添加了一些软件包以使用 dotnet aspnet-codegenerator
工具.我的 .csproj
看起来像这样:
< Project Sdk ="Microsoft.NET.Sdk.Web">< PropertyGroup>< TargetFramework> netcoreapp3.1</TargetFramework>< RootNamespace> test_project</RootNamespace></PropertyGroup>< ItemGroup>< PackageReference Include ="Microsoft.VisualStudio.Web.CodeGeneration.Design";版本="3.1.4"./>< PackageReference Include ="Microsoft.AspNetCore.Identity.EntityFrameworkCore";版本="3.1.7"./>< PackageReference Include ="Microsoft.AspNetCore.Identity.UI";版本="3.1.7"./>< PackageReference Include ="Microsoft.EntityFrameworkCore";版本="3.1.7"./>< PackageReference Include ="Microsoft.EntityFrameworkCore.Design";版本="3.1.7"< IncludeAssets>运行时;建造;本国的;内容文件;分析仪;buildtransitive</IncludeAssets>< PrivateAssets>全部</PrivateAssets></PackageReference>< PackageReference Include ="Microsoft.EntityFrameworkCore.Tools";版本="3.1.7"< IncludeAssets>运行时;建造;本国的;内容文件;分析仪;buildtransitive</IncludeAssets>< PrivateAssets>全部</PrivateAssets></PackageReference>< PackageReference Include ="Newtonsoft.Json";版本="12.0.3"/>< PackageReference Include ="Npgsql.EntityFrameworkCore.PostgreSQL";版本="3.1.4"./>< PackageReference Include ="Npgsql.EntityFrameworkCore.PostgreSQL.Design";版本="1.1.0&"/></ItemGroup></Project>
如您所见, Microsoft.VisualStudio.Web.CodeGeneration.Design
是列表中的第一位.但是,当我尝试通过 dotnet aspnet-codegenerator
工具运行任何脚手架时(例如: dotnet aspnet-codegenerator身份-h
),我收到以下消息:>
此项目中没有代码生成器.将Microsoft.VisualStudio.Web.CodeGeneration.Design软件包作为NuGet软件包引用添加到项目中.
即使我使用 -p
标志指定了<code> .csproj 文件,我仍然会收到相同的消息.在进行一些研究时,我发现这问题出现在他们的仓库中,但这是另一回事:OP尝试使用3.1脚手架版本将脚手架添加到.NET Core App 3.0.
我正在Xubuntu 20.04上使用dotnet 3.1.401.
有什么想法吗?预先谢谢你.
编辑1 有人认为这将接近我们在此处的功能,但问题是:我知道它的作用,并且我实际上添加了全局工具"在该文章中建议.问题是 aspnet-codegenerator
没有检测到我已经拥有了它需要的东西,已经将它添加到 .csproj
文件中.
编辑1
显然,也有一些人也面临此问题,因此,我提交了问题在他们的仓库中
如存储库 maintainer 所述我在问题中上面提到的问题根据运行时/目标更新其软件包:
使用dotnet工具更新dotnet-aspnet-codegenerator -g --version 3.1.5/5.0.2,具体取决于您定位的是.netcoreapp3.1还是net5.0.[...]您还需要更新Microsoft.VisualStudio.Web.CodeGeneration.Design程序包.
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
As mentioned by the repository maintainer on the issue I mentioned above in the question, one with this problem should update its packages according to the runtime/target:
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. [...] You will also need to update the Microsoft.VisualStudio.Web.CodeGeneration.Design package as well.
这篇关于dotnet aspnet代码生成器工具找不到Microsoft.VisualStudio.Web.CodeGeneration.Design的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!