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'"
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>
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"
]
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With