Output of dotnet --info:
.NET Core SDK (reflecting any global.json):
Version: 3.1.302
Commit: 41faccf259
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/3.1.302/
Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1
.NET Core SDKs installed:
3.1.302 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
While following the Microsoft docs guide on scaffolding Identity, I was unable to scaffold Identity, presumably because the scaffolder is looking for files with the naming pattern Filename.cs.cshtml instead of Filename.cshtml.cs.
I initially tried scaffolding with a netcoreapp3.1 with Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.4, but when this failed I tried with netcoreapp3.0 and Microsoft.VisualStudio.Web.CodeGeneration.Design 3.0.0. Both runs were identical.
dotnet tool install -g dotnet-aspnet-codegeneratordotnet new mvc -n IdentityApp -au Identitycd into the new project directoryMicrosoft.VisualStudio.Web.CodeGeneration.DesignMicrosoft.EntityFrameworkCore.SqlServer because scaffolding doesn't seem to work without itdotnet aspnet-codegenerator identity -dc IdentityApp.Data.ApplicationDbContextAll Identity.UI Razor Pages are scaffolded into the project
A fatal error indicating a file was not found:
Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
A file matching the name Account.AccessDenied.cs.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:16.85
For the record, I am able to boot into Windows and everything works as expected using the CLI (latest major Windows release, same dotnet version, same project specs, same steps to reproduce). My setup is dual-boot, not WSL (not sure if that would make a difference).
Hmm interesting. I'll test on ubuntu and get back to you. Would you able to send me your project.assets.json file in the obj folder of the project. Might be due to how I build the dependency graph based on that file.
You may try using the newer sdk 3.1.401 but don't think thats where the issue is.
Thanks.
I had to downgrade dotnet-sdk-3.1 to 3.1.302 and aspnet-codegenerator to 3.1.3 to fix this issue. (Solution found by @undmeer for this issue 1384)
I have the same problem, do I need to downgrade my versions?
Hello,
This is still happening with the dotnet-sdk-5.0 & latest version of the codegenerator on ubuntu 20.04, also had the same issue with sdk version 3.1.4.
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /usr/share/dotnet/sdk/5.0.100/
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
5.0.100 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Error:
Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
A file matching the name ApplicationDbContext.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:05.77
I have a similar error when I try to scaffold a controller:
Building project ...
Finding the generator 'controller'...
Running the generator 'controller'...
A file matching the name EmptyController.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:04.06
In the same solution, if i try this command: dotnet aspnet-codegenerator -h :
Usage: aspnet-codegenerator [arguments] [options]
Arguments:
generator Name of the generator. Check available generators below.
Options:
-p|--project Path to .csproj file in the project.
-n|--nuget-package-dir
-c|--configuration Configuration for the project (Possible values: Debug/ Release)
-tfm|--target-framework Target Framework to use. (Short folder name of the tfm. eg. net46)
-b|--build-base-path
--no-build
No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
RunTime 00:00:01.21
Until this issue is fixed, it is possible to downgrade net core sdk with the following commands:
sudo apt-get remove dotnet-sdk-3.1 --purge
sudo apt-get install dotnet-sdk-3.1=3.1.302-1
sudo apt-mark hold dotnet-sdk-3.1
dotnet tool uninstall -g dotnet-aspnet-codegenerator
dotnet tool install -g dotnet-aspnet-codegenerator --version 3.1.3
Same issue.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
dotnet aspnet-codegenerator identity --useDefaultUI
Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
A file matching the name ApplicationDbContext.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:05.63`
Until this issue is fixed, it is possible to downgrade net core sdk with the following commands:
sudo apt-get remove dotnet-sdk-3.1 --purge
sudo apt-get install dotnet-sdk-3.1=3.1.302-1
sudo apt-mark hold dotnet-sdk-3.1
dotnet tool uninstall -g dotnet-aspnet-codegenerator
dotnet tool install -g dotnet-aspnet-codegenerator --version 3.1.3
Thanks this worked for me, I also had to append a version to the packages I added.
dot net add package Microsoft..........MySQLServer --version 3.1.0
As an example.
I can't downgrade as I need NET5 not NET3.
Has anyone managed to get this to work with NET5?
Yes, easily. Create in NET3.1 then upgrade to NET5
@rolambert Interesting... but surely there has been changes to the templates between 3 and 5?
There seems to be an issue with the .nuget cache folder ( /home/username/.nuget in Linux ) if it resides in a Case Sensitive filesystem (Linux and Mac).
A way to temporarily avoid this problem seems to be mounting that folder in a Case Insensitive filesystem like it's explained in a similar Issue: https://github.com/dotnet/Scaffolding/issues/1393#issuecomment-752041418
Thanks that's a decent workaround for now.
I guess the dotnet guys are all using windows else they'd have encountered this problem themselves. :stuck_out_tongue_closed_eyes:
I hope it gets some attention soon, as scaffolding is totally broken in linux / net5. And it's so useful.
@lonix1 @rolambert @KBastin @tedesco8 @christianspeegle
I have a fix for this issue out with a new 3.1.5 and 5.0.2 package out.
Use dotnet tool update dotnet-aspnet-codegenerator -g --version 3.1.5/5.0.2 depending on if you are targeting .netcoreapp3.1 or net5.0. I would like it if someone could confirm the fix before I close the issue.
Apologize for the lengthy delay on this fix and appreciate all the feedback.
Fix seems to work. Closing
Most helpful comment
Thanks that's a decent workaround for now.
I guess the dotnet guys are all using windows else they'd have encountered this problem themselves. :stuck_out_tongue_closed_eyes:
I hope it gets some attention soon, as scaffolding is totally broken in linux / net5. And it's so useful.