question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running aspnet-codegenerator I get: MvcControllerWithContext.cshtml no found.

See original GitHub issue

Steps to reproduce:

Following the MVC Net Core tutorial until this point. Install locally dotnet-ef and dotnet-aspnet-codegenerator and the following packages.

Steps later in the tutorial, run this: export PATH=$HOME/.dotnet/tools:$PATH, and this(my case):

dotnet aspnet-codegenerator controller -name SessionController -m Session -dc ApplicationDbContext --relativeFolderPath Controllers --useDefaultLayout --referenceScriptLibraries

Expected behavior:

Generate SessionControllers and Views.

Actual behavior:

I get this error:

Building project ...
Finding the generator 'controller'...
Running the generator 'controller'...
Attempting to compile the application in memory.
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'Session'
A file matching the name MvcControllerWithContext.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:07.88

EDIT:

I installed dotnet-ef and dotnet-aspnet-codegenerator globally, but I get the same error. I notice that I have configured this var: NUGET_PACKAGES=/home/dlag/.config/nuget/packages. In that path, I have the error file: packages/microsoft.visualstudio.web.codegenerators.mvc/3.1.2/Templates/ControllerGenerator/MvcControllerWithContext.cshtml I try coping .config/nuget to .nuget but same error. How can I tell dotnet to look for this path?

Additional information about the project being scaffolded, such as:

System:

5.7.12-arch1-1

Target framework(s):

dotnet 3.1.106 Microsoft.EntityFrameworkCore.Tools 3.1.6

Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding:

3.1.4

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:28 (2 by maintainers)

github_iconTop GitHub Comments

49reactions
LeandroRezendeCoutinhocommented, Nov 28, 2020

Solution commands On project folder execute

mkdir Templates && mkdir Templates/ControllerGenerator && mkdir Templates/ViewGenerator

cp -r /home/$USER/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/5.0.0/Templates/ControllerGenerator/* ./Templates/ControllerGenerator

cp -r /home/$USER/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/5.0.0/Templates/ViewGenerator/* ./Templates/ViewGenerator/

11reactions
luanphamngcommented, Aug 10, 2020

Hello dlagg, I found the way how to solve this. Please downgrade your version from v3.1.4 to v3.1.0 by using these commands:

dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffolding using terminal dosen't work - Microsoft Q&A
I was following the ASP.NET Core MVC tutorial from adding-model but when I run the command dotnet aspnet-codegenerator controller -name ...
Read more >
Problem scaffolding new controller using Entity Framework ...
I can generate a controller, but without EF in both choices unfortunately. Rider generate an empty controller. My problem is generating them ...
Read more >
There Was An Error Running The Selected Code Generator
Net Core Controller inside the project using scaffolding mechanism with ... Recommended Courses ➤ Asp.Net Core MVC : https://bit.ly/3S4Ec5B ...
Read more >
Problem scaffolding new controller using Entity Framework ...
Reading this issue on GitHub helped me to find a workaround. ... 'Person' A file matching the name MvcControllerWithContext.cshtml was not found within...
Read more >
There was an error running the selected code generator in ...
The following steps use the aspnet-codegenerator tool to scaffold the full Identity pages area into your .Net Core 5 app. Close Visual Studio....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found