dotnet / Scaffolding

Code generators to speed up development.
MIT License
642 stars 229 forks source link

Still a problem with Dotnet core 3.1.301 #1382

Open eren-dhoheiri opened 4 years ago

eren-dhoheiri commented 4 years ago

Still a problem with Dotnet core 3.1.301 the output of dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.1.302
 Commit:    41faccf259

Runtime Environment:
 OS Name:     zorin
 OS Version:  15
 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]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

output of dotnet aspnet-codegenerator controller -name ServerController -async -api -m Server -dc ServerContext -outDir Controllers

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: 'Server'
A file matching the name ApiControllerWithContext.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.48

output of ls -l ~/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/3.1.4/Templates/ControllerGenerator/

total 36
-rwxrw-r-- 1 jared jared  1293 Aug  3 18:28 ApiControllerWithActions.cshtml
-rwxrw-r-- 1 jared jared  4901 Aug  3 18:28 ApiControllerWithContext.cshtml
-rwxrw-r-- 1 jared jared   411 Aug  3 18:28 ApiEmptyController.cshtml
-rwxrw-r-- 1 jared jared  2389 Aug  3 18:28 ControllerWithActions.cshtml
-rwxrw-r-- 1 jared jared   407 Aug  3 18:28 EmptyController.cshtml
-rwxrw-r-- 1 jared jared 10197 Aug  3 18:28 MvcControllerWithContext.cshtml

Originally posted by @Jaredes0514 in https://github.com/dotnet/Scaffolding/issues/559#issuecomment-668844613

Rick-Anderson commented 4 years ago

possible dup of #1384 @eren-dhoheiri can you change the title to "A file matching the name ApiControllerWithContext.cshtml" ?

lampsbr commented 3 years ago

I just installed dotnet 5 in my ubuntu 20.04, was following the rest api tutorial and this problem still exists.

marcovelarde commented 3 years ago

Same problem here using dotnet 5.

Hackjaku commented 3 years ago

Same using dotnet 5 on Linux

Rick-Anderson commented 3 years ago

Try the following:

dotnet tool  uninstall  -g dotnet-aspnet-codegenerator
dotnet tool install -g dotnet-aspnet-codegenerator
lampsbr commented 3 years ago

@Rick-Anderson I tried but it still didn't work:

$ dotnet tool uninstall -g dotnet-aspnet-codegenerator Tool 'dotnet-aspnet-codegenerator' (version '5.0.0') was successfully uninstalled. $ dotnet tool install -g dotnet-aspnet-codegenerator You can invoke the tool using the following command: dotnet-aspnet-codegenerator Tool 'dotnet-aspnet-codegenerator' (version '5.0.0') was successfully installed. $ dotnet aspnet-codegenerator controller -name TodoItemsController -async -api -m TodoItem -dc TodoContext -outDir Controllers 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: 'TodoItem' A file matching the name ApiControllerWithContext.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:09.09

Rick-Anderson commented 3 years ago

@lampsbr we've got thousands of customers reporting success. Most likely, you're missing a step or something is wrong with your computer. If you're confident you haven't missed a step, you could try the following:

Yakkhini commented 3 years ago

There is a templates folder in /home/yourusername/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/5.0.1/, which contains many templates needed, but in ubuntu, Vscode can't use it correctly. So you can copy whole Templates folder in your project folder(without two identity template subfolders).