Views/Shared/_Layout.cshtml not updated when scaffolding identity in 2.2 release

Open Beginner friendly
#931 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
csharp
Domain
tooling

Research direction

Reproduce the identity scaffolding with the dotnet-aspnet-codegenerator identity command and inspect Views/Shared/_Layout.cshtml and Views/Shared/_LoginPartial.cshtml. Compare the generated layout with the reported workaround. Done means the generated layout references the login partial and the running app shows a working Login link.

Written by the indexing model from the issue text.

Description

area-identity area-scaffolding

Steps to reproduce:

Install release version of SDK 2.2 on Mac

dotnet --version

2.2.100

dotnet new  mvc

Then init a git repo with suitable .gitignore and commit everything so we can easily see what was changed.

Add the scaffolded identity files:

dotnet tool update --global dotnet-aspnet-codegenerator

Tool 'dotnet-aspnet-codegenerator' was successfully updated from version '2.1.6' to version '2.2.0'.

Add this to csproj file as requested when attempting to run the generator:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2" PrivateAssets="All" />

dotnet restore

Run the code generator:

dotnet-aspnet-codegenerator identity

Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
RunTime 00:00:12.66

Run the app and notice there is no "Login" link in the nav bar.

Checking the contents of "Views/Shared/_Layout.cshtml" shows that the file "Views/Shared/_LoginPartial.cshtml" which was added by the code generator is not referenced and git shows no changes to the file.

Despite the lack of warning about updating existing file, run the generator again with the '--force' option:

Run the code generator with --force:

dotnet-aspnet-codegenerator identity --force

No difference.

Running:

dotnet-aspnet-codegenerator -h

shows there the force option is no longer there?

Expected behavior:

It should not generate broken scaffolding, the "Login" link should be there, it should work as it did previously in 2.1.

Actual behavior:

Code generator generates broken scaffolding for identity

Workaround:

This is easily be fixed by adding the partial to _Layout.cshtml, right after the navbar markup:

<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
    ..............                
</div>
<partial name="_LoginPartial" />

Seems there is also another issue with identity scaffolding, which i think also existed in 2.1
https://github.com/aspnet/Scaffolding/issues/884

Dominant language
C#
Stars
818
Forks
261
Avg merge
1d 16h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/Scaffolding

All issues in dotnet/Scaffolding

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.