dotnet / dotnet/Scaffolding

"Path is empty" error when scaffolding in a project that references Microsoft.AspNetCore.Identity

Open
#1,713 4 comments 0 reactions 0 assignees View on GitHub
area-scaffolding customer-reported
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

### Issue

The following error is thrown when running the command `dotnet aspnet-codegenerator identity -lf`.
The same error (sans stack trace) also occurs when attempting to scaffold any view via the IDE context menu.

```
[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.<b__0>d.MoveNext()
RunTime 00:00:02.43
```

### Reproduction Steps

1) Create a new project using the template "ASP.NET Core Web App (Model-View-Controller)" targeting .NET 6.0 and with the authentication type set to Individual Accounts.
2) Add the following Nuget package:
- Microsoft.VisualStudio.Web.CodeGeneration.Design (to support scaffolding)
3) Save all files (Ctrl + Shift + S) and rebuild the solution.
4) At this point, open cmd to the project file's directory and run `dotnet aspnet-codegenerator identity -lf` to ensure the list of available Identity views for scaffolding is shown successfully.
5) Add the following Nuget package:
- Microsoft.AspNetCore.Identity
6) Save all files (Ctrl + Shift + S) and rebuild the solution.
7) Try to re-run the command `dotnet aspnet-codegenerator identity -lf` and the above error should occur.

### Environment Info

**Target framework:** .NET 6.0
**IDE:** Visual Studio 2022 17.0.1
**Operating system:** Windows Server 2016 Standard

Issue originally posted [on StackOverflow](https://stackoverflow.com/questions/70119631/aspnet-codegenerator-error-path-is-empty) (by me).

Contributor guide

Open the contributing guide

Research direction

Start with the failing stack-trace entry point, ProjectContextWriter.GetScaffoldingAssemblies, and then inspect ProjectContextExtensions.AddPackageDependencies. Reproduce the failure with the listed ASP.NET Core .NET 6 project steps and the Microsoft.AspNetCore.Identity package, then verify that identity and view scaffolding no longer reports an empty path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.