aspnet-codegenerator fails to create an API with actions on Ubuntu
See original GitHub issuesteps to reproduce
-
dotnet new webapi -o WebApi
-
change
WebApi.csproj
to be:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.Composition" Version="1.0.31" ExcludeAssets="All" />
<PackageReference Include="System.Composition" Version="1.0.31" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
</Project>
-
dotnet restore
-
dotnet aspnet-codegenerator controller -name NotGonnaUseController -api -actions -outDir Controllers
Command Line: controller -name NotGonnaUseController -api -actions -outDir Controllers
Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Building project ...
Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
WebApi -> /home/badersur/Coding/MVA/ASP.NETCore-p1/WebApi/bin/Debug/netcoreapp1.1/WebApi.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.92
Command Line: --no-dispatch --port-number 52613 controller -name NotGonnaUseController -api -actions -outDir Controllers --dispatcher-version 1.0.1-rtm
Finding the generator 'controller'...
Running the generator 'controller'...
A file matching the name ApiControllerWithActions.cshtml was not found within any of the folders: /home/badersur/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/1.1.1/Templates/ControllerGenerator;/home/badersur/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/1.1.1/Templates/ViewGenerator
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:06.69
ls -l /home/badersur/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/1.1.1/Templates/ControllerGenerator
total 36
-rwxrw-rw- 1 badersur badersur 1375 Apr 28 01:36 ApiControllerWIthActions.cshtml
-rwxrw-rw- 1 badersur badersur 5074 Apr 28 01:36 ApiControllerWithContext.cshtml
-rwxrw-rw- 1 badersur badersur 614 Apr 28 01:36 ApiEmptyController.cshtml
-rwxrw-rw- 1 badersur badersur 2371 Apr 28 01:36 ControllerWithActions.cshtml
-rwxrw-rw- 1 badersur badersur 407 Apr 28 01:36 EmptyController.cshtml
-rwxrw-rw- 1 badersur badersur 10218 Apr 28 01:36 MvcControllerWithContext.cshtml
It seems like the issue is because ApiControllerWithActions.cshtml
is named ApiControllerWIthActions.cshtml
by mistake!
dotnet --info
.NET Command Line Tools (1.1.0-preview1-005051)
Product Information:
Version: 1.1.0-preview1-005051
Commit SHA-1 hash: 5e88564e56
Runtime Environment:
OS Name: ubuntu
OS Version: 17.04
OS Platform: Linux
RID: ubuntu.16.10-x64
Base Path: /usr/share/dotnet/sdk/1.1.0-preview1-005051
Issue Analytics
- State:
- Created 6 years ago
- Comments:20
Top Results From Across the Web
dotnet aspnet-codegenerator command
Generate controller with read/write actions without a model. Use the -h switch for help on the aspnet-codegenerator controller command: .NET CLI
Read more >c# - aspnet-codegenerator could not execute
Possible reasons for this include: * You misspelled a built-in dotnet command. * You intended to execute a .NET Core program, but dotnet-aspnet- ......
Read more >There Was An Error Running The Selected Code Generator
Recommended Courses ➤ Asp.Net Core MVC: https://bit.ly/3S4Ec5B ➤ Entity Framework Core: https://bit.ly/3cGJUud ➤ Asp.Net Core Web API ...
Read more >ASP.NET Core 2: Doing scaffolding with dotnet CLI
Create the scaffolding using the following command “dotnet-aspnet-codegerator controller -name ExampleController -actions -api -outDir ...
Read more >How to Build CRUD REST APIs with ASP.NET Core 3.1 ...
Step 1: Right–click the Controllers folder, choose Add, and then click Controller. Step 2: Select API Controller with actions using the Entity ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the solution for UBUNTU valid for net core 3.0 , 3.1 and 5.0.
27/NOVEMBER/2020
ControllerGenerator contains de file MvcControllerWithContext.cshtml
You just have to copy the Template folders Template/ControllerGenerator and Templete/ViewGenerator to own project.
This is the path of the missing files:
/home/$USER/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/5.0.0/Templates
@whittingtonandy downgrading to any 3.x version below 3.1.4 gives me “No code generators found with the name ‘controller’” instead