Running aspnet-codegenerator I get: MvcControllerWithContext.cshtml no found.
See original GitHub issueSteps 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:
- Created 3 years ago
- Comments:28 (2 by maintainers)
Top GitHub Comments
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/
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: