[英]dotnet tool aspnet-codegenerator looks for executable at wrong path
[英]aspnet-codegenerator error: "path is empty"
我正在嘗試為新的 .NET 6.0 項目(從 ASP.NET 核心 MVC 模板創建)搭建身份頁面。 當我運行以下命令時,我收到錯誤“路徑為空”(我還包括構建命令 output 以顯示項目構建成功)。
> dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
ExampleProject -> C:\...\bin\Debug\net6.0\ExampleProject.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.52
> dotnet aspnet-codegenerator identity -lf
[Trace]: Command Line: identity -lf
Building project ...
[Trace]: Command Line: --no-dispatch --port-number 64193 identity -lf --dispatcher-version 6.0.0+cc9d1f5236d926269a0471042f72bf83b498509c
Scaffolding failed.
The path is empty. (Parameter 'path')
[Trace]: at System.IO.Path.GetFullPath(String path)
at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
at Microsoft.VisualStudio.Web.CodeGeneration.Msbuild.ProjectContextWriter.GetScaffoldingAssemblies(IEnumerable`1 dependencies)
at Microsoft.DotNet.Scaffolding.Shared.ProjectModel.ProjectContextExtensions.AddPackageDependencies(IProjectContext projectInformation, String projectAssetsFile)
at Microsoft.VisualStudio.Web.CodeGeneration.Design.Program.<>c__DisplayClass4_0.<<Execute>b__0>d.MoveNext()
RunTime 00:00:02.43
當嘗試通過 Visual Studio 2022 中的添加 -> 視圖上下文菜單構建新的 Razor 視圖(例如創建)時,也會出現此錯誤“路徑為空”(沒有堆棧跟蹤)。
這是配置問題,還是代碼生成器中的錯誤?
編輯(2021-11-29):從頭開始重現此錯誤后,似乎在將Microsoft.AspNetCore.Identity
Nuget package 添加到項目后發生,如下所示。
復制步驟:
使用針對 .NET 6.0 的模板“ASP.NET Core Web App (Model-View-Controller)”在 Visual Studio 2022 中創建一個新項目,並將身份驗證類型設置為個人帳戶。
添加以下 Nuget package:
保存所有文件 (Ctrl + Shift + S) 並重建解決方案。
此時,打開 cmd 到項目文件的目錄並運行“dotnet aspnet-codegenerator identity -lf”以確保成功顯示腳手架的可用身份視圖列表。
添加以下 Nuget package:
保存所有文件 (Ctrl + Shift + S) 並重建解決方案。
嘗試重新運行命令“dotnet aspnet-codegenerator identity -lf”,應該會出現以下錯誤:
[Trace]: Command Line: identity -lf Building project... [Trace]: Command Line: --no-dispatch --port-number 57313 identity -lf --dispatcher-version 6.0.0+cc9d1f5236d926269a0471042f72bf83b498509c Scaffolding failed. The path is empty. (Parameter 'path') [Trace]: at System.IO.Path.GetFullPath(String path) at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options) at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized) at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options) at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options) at Microsoft.VisualStudio.Web.CodeGeneration.Msbuild.ProjectContextWriter.GetScaffoldingAssemblies(IEnumerable`1 dependencies) at Microsoft.DotNet.Scaffolding.Shared.ProjectModel.ProjectContextExtensions.AddPackageDependencies(IProjectContext projectInformation, String projectAssetsFile) at Microsoft.VisualStudio.Web.CodeGeneration.Design.Program.<>c__DisplayClass4_0.<<Execute>b__0>d.MoveNext() RunTime 00:00:03.53
正如對問題和本網站的評論所述
https://github.com/dotnet/Scaffolding/issues/1713
從相關解決方案中的所有項目中刪除 nuget package Microsoft.AspNetCore.Identity
即可解決問題。
在許多情況下(也在我的)它足以引用 nuget package Microsoft.AspNetCore.Identity.EntityFrameworkCore
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.