[英]How to determine if Microsoft.VisualStudio.Web.CodeGeneration.Design is being used?
[英]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" 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>
如您所見, Microsoft.VisualStudio.Web.CodeGeneration.Design
是列表中的第一個。 但是,當我嘗試從dotnet aspnet-codegenerator
工具(例如: dotnet aspnet-codegenerator identity -h
)運行任何腳手架時,我收到以下消息:
No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
即使我使用-p
標志指定.csproj
文件,我仍然會收到相同的消息。 在進行一些研究時,我在他們的倉庫中發現了這個問題,但這是另一回事:OP 試圖使用 3.1 腳手架版本將腳手架添加到 .NET Core App 3.0 中。
我在 Xubuntu 20.04 上使用 dotnet 3.1.401。
有什么想法嗎? 先感謝您。
編輯 1有人建議這將接近我們在這里所擁有的,但問題是:我知道它的作用,並且我實際上添加了該文章中建議的“全局工具”。 問題是aspnet-codegenerator
沒有檢測到我已經擁有它需要的庫,添加到.csproj
文件中。
編輯 1
顯然,有幾個人也面臨這個問題,所以,我在他們的回購中提出了一個問題
這已經有幾個月了,但我最近在我的所有項目中都遇到了它。
如果其他人登陸此頁面,我的解決方案(MAC OS)是卸載並重新安裝dotnet-aspnet-codegenerator
。
在終端中運行:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
相關主題在這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.