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_
possible dup of #1384
@eren-dhoheiri can you change the title to "A file matching the name ApiControllerWithContext.cshtml" ?
I just installed dotnet 5 in my ubuntu 20.04, was following the rest api tutorial and this problem still exists.
Same problem here using dotnet 5.
Same using dotnet 5 on Linux
Try the following:
dotnet tool uninstall -g dotnet-aspnet-codegenerator
dotnet tool install -g dotnet-aspnet-codegenerator
@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
@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:
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).
Most helpful comment
I just installed dotnet 5 in my ubuntu 20.04, was following the rest api tutorial and this problem still exists.