aspnet代码生成器标识列表选项导致脚手架失败错误



浏览本教程ASP.NET核心项目中的脚手架标识。

我按照写的做了所有的事情,所以下面是复制的步骤:

  1. 创建一个.net核心项目(与vs 2019一起命名为"DotNetCorePlayGround"(。

  2. 从包管理器控制台运行以下命令:

    dotnet tool install -g dotnet-aspnet-codegenerator

  3. 和:

    dotnet add dotnetcoreplayground package Microsoft.VisualStudio.Web.CodeGeneration.Design dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.Design dotnet add dotnetcoreplayground package Microsoft.AspNetCore.Identity.EntityFrameworkCore dotnet add dotnetcoreplayground package Microsoft.AspNetCore.Identity.UI dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.SqlServer dotnet add dotnetcoreplayground package Microsoft.EntityFrameworkCore.Tools

一切如预期,结果是:

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
</ItemGroup>

问题出在这一行(仅尝试列出Identity脚手架工选项(:

dotnet aspnet-codegenerator identity -h

结果是:

dotnet : Scaffolding failed.
At line:1 char:1
+ dotnet aspnet-codegenerator identity -h p C:Users[user]sou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (Scaffolding failed.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Could not find project file in C:Users[user]sourcereposDotnetCoreplayGround

知道为什么找不到项目文件吗?

我尝试运行:

dotnet aspnet-codegenerator -help并得到脚手架失败错误。问题是我的.config文件夹被删除了(我不知道为什么(。。。

我如何解决问题:

我在其中创建了一个新的.config文件夹和一个新dotnet-tools.json文件。

文件内容:

{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.3",
"commands": [
"dotnet-ef"
]
},
"dotnet-aspnet-codegenerator": {
"version": "3.1.1",
"commands": [
"dotnet-aspnet-codegenerator"
]
}
}
}

然后转到终端并运行dotnet工具还原。

就这样!

最新更新