Scaffolding: No executable found matching command "dotnet-aspnet-codegenerator"

Created on 8 Mar 2019  路  15Comments  路  Source: dotnet/Scaffolding

Describe the bug

At this point of the tutorial : https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.0&tabs=visual-studio-code#scaffold-the-movie-model we are asked to install the dotnet-aspnet-codegenerator tool. There is no problem installing it but as soon as I try to execute the command dotnet aspnet-codegenerator razorpage -m Movie -dc RazorPagesMovieContext -udl -outDir Pages/Movies --referenceScriptLibraries I've got this error in terminal : Aucun ex茅cutable ne correspond 脿 la commande "dotnet-aspnet-codegenerator"

I have try everything found on other issues that seems similar but most of them are related to version 2.2.0... and wont work :(

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '2.2.104'
  2. (Follow the tutorial until you are asked to) Run this code dotnet aspnet-codegenerator razorpage
  3. With these arguments -m Movie -dc RazorPagesMovieContext -udl -outDir Pages/Movies --referenceScriptLibraries
  4. See error : Aucun ex茅cutable ne correspond 脿 la commande "dotnet-aspnet-codegenerator"

Expected behavior

In my opinion it should generate the proper views ;-)

Additional context

Using zsh instead of bash, no idea if this can help...

Output of dotnet --info

SDK .NET Core (refl茅tant tous les global.json) :
 Version:   2.2.104
 Commit:    73f036d4ac

Environnement d'ex茅cution :
 OS Name:     ubuntu
 OS Version:  18.10
 OS Platform: Linux
 RID:         ubuntu.18.10-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.104/

Host (useful for support):
  Version: 2.2.2
  Commit:  a4fd7b2c84

.NET Core SDKs installed:
  2.2.104 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Most helpful comment

$HOME/.dotnet/tools is what you need to add to path

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

All 15 comments

A little update if it can help...
As stated here calling the dotnet-aspnet-codegenerator command from within the installation folder works :

  • cd /home/me/.dotnet/tools/
  • ./dotnet-aspnet-codegenerator -h
Scaffolding failed.
Could not find project file in /home/me/.dotnet/tools

Thanks for contacting us, @pitrackster.
@vijayrkn can you please assign as necessary? Thanks!

@pitrackster - Can you please share the package references in your project?

  • @seancpeters

Hi !
Below is the content of my RazorPageMovie.csproj file

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SQLite" Version="2.2.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.2" />
  </ItemGroup>

</Project>

Can you update the version of CodeGenerator.Design to 2.2.3. Also, can you confirm if this works from Visual Studio?

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.2" />

I'll check if it works with the updated version as soon as possible. But as I use Linux I wont be able to tell if it works from VisualStudio.

Hi. Just updated the version of CodeGenerator to 2.2.3 but it does not solve the issue.

Tried to do it again from scratch and still have the same error ... quite disappointing...

.csproj file

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SQLite" Version="2.2.3" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
  </ItemGroup>

</Project>

dotnet --info

SDK .NET Core (refl茅tant tous les global.json)聽:
 Version:   2.2.105
 Commit:    7cecb35b92

Environnement d'ex茅cution聽:
 OS Name:     ubuntu
 OS Version:  18.10
 OS Platform: Linux
 RID:         ubuntu.18.10-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.105/

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.2.105 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

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

@seancpeters - Any idea why it would fail to find the code generator from commanline?

Aucun ex茅cutable ne correspond 脿 la commande "dotnet-aspnet-codegenerator"

/cc @wli3

It could be the shell. What shell are you using? We global tools currently can only automatically add PATH to bash. And could you show us the $PATH? Is /home/me/.dotnet/tools/ in it?

@wli3 Hi !

I am using zsh instead of bash so this might be the problem !
And in fact .dotnet/tools is not in the $PATH variable...

Could you please provide me the PATH I should add to my .zshrc ?
Thanks

$HOME/.dotnet/tools is what you need to add to path

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

@wli3 works like a charm !

Thanks everyone !

Thanks guys!

$HOME/.dotnet/tools is what you need to add to path

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

Thanks! <3

Was this page helpful?
0 / 5 - 0 ratings