Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No executables found matching command 'dotnet-aspnet-codegenerator'"

When trying to add a Controller in an ASP.NET Core project using Visual Studio 15 Enterprise with Update 3, I get the error below:

"The was an error running the selected code generator: No executables found matching command 'dotnet-aspnet-codegenerator'"

like image 671
Darren Alfonso Avatar asked Jan 03 '17 18:01

Darren Alfonso


4 Answers

If you're using csproj (Visual Studio 2017) instead of project.json, then you need to add the following to your csproj file:

    <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
    </ItemGroup>
like image 55
johnnycardy Avatar answered Nov 15 '22 21:11

johnnycardy


For the latest version, in project.json add the following under dependencies:

"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
  "version": "1.1.0-preview4-final",
  "type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
  "type": "build",
  "version": "1.1.0-preview4-final"
}

and the following under tools:

"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
  "version": "1.1.0-preview4-final",
  "imports": [
    "portable-net45+win8"
  ]
}
like image 33
Techy Avatar answered Nov 15 '22 21:11

Techy


If you are using Mac (OS X) or any supported distribution of Linux, you have to run:

dotnet tool install --global dotnet-aspnet-codegenerator --version 2.2.3

Additionally, on Mac I added to my .zshrc (or bash equivalent)

export PATH=$HOME/.dotnet/tools:$PATH

And I had to make sure to restart Terminal.

like image 8
Paul Avatar answered Nov 15 '22 22:11

Paul


A more robust answer than copying version numbers into your configuration file is to use NuGet to ensure that the packages are added to your project.

Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.

First, get everything up to date. Choose the Updates tab. Check the box for Update All and run this a few times. Don't be surprised if some stuff downgrades the first couple of times you run the upgrade. Some dependencies seem to have to be handled sequentially. It took me about 5 upgrades to get everything up to date.

Then, in the browse tab, search for CodeGeneration.Tools. Install it. Do the same for CodeGenerators.Mvc. As you find additional error messages, you should be able to find any missing packages in NuGet.

like image 7
Josiah Avatar answered Nov 15 '22 21:11

Josiah