I'm learning ASP.net, so I'm reading https://learn.microsoft.com/fr-fr/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.0&tabs=visual-studio-code and in the section Scaffold the movie model, I must install and run the CRUD tool (ASP.net Core dotnet-aspnet-codegenerator). The problem I encounter is I can't use their tool, an error is output ; however I could install it. Below are the details.
So I'm following the three-steps tutorial to use this CRUD code generator (link given above). I quote:
- Open a command window in the project directory (The directory that contains the Program.cs, Startup.cs, and .csproj files).
✔ It worked.
- Install the scaffolding tool:
dotnet tool install --global dotnet-aspnet-codegenerator
✔ It worked and now if I try to re-install it, it outputs that it's already installed.
- For macOS and Linux: Run the following command:
dotnet aspnet-codegenerator razorpage -m Movie -dc RazorPagesMovieContext -udl -outDir Pages/Movies --referenceScriptLibraries
🐛 It doesn't work. Here is the output error:
Could not execute because the specified command or file was not found. Possible reasons for this include: * You misspelled a built-in dotnet command. * You intended to execute a .NET Core program, but dotnet-dotnet-aspnet-codegenerator does not exist. * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Question : How can I debug it to make this command work?
Oh, oh... "Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed." - i didn't read it, this is ouput by the CLI at the installation of the codegenerator.
UPDATE: it didn't solve my problem (I re-run my computer & Ubuntu session) with both versions 3.0.0 and 2.1.10 of the codegenerator :(...
Sometimes the latest version might be inconsistent. try with older versions and see if there is any difference. Start with highest version before your current one and go down to find one that actually works. How to install older vesions:
dotnet tool install --global dotnet-aspnet-codegenerator --version {version}
You may find version history in the nuget page:
https://www.nuget.org/packages/dotnet-aspnet-codegenerator/
In my case the installer added the wrong path to the Path
environment variable.
The path added was pointing to a non existing folder under Programs. It needs to point to dotnet-aspnet-codegenerator.exe
.
For me the correct path was in my user folder: ~\.dotnet\tools
You can check if the correct path was added by running: echo $env:Path
If the path is missing or incorrect you just need to add the correct path to the Path
system environment variable.
You might be able to test this by using PowerShell to set your local variable: $env:Path += ";C:\Users\<YOUR_NAME_HERE>\.dotnet\tools"
But I haven't tried this.
Environment
in the windows search and you should see the Control panel
option to Edit system environment variables
.Environment Variables...
button in the lower right corner.System variables
find and select the Path
variable, then click Edit
.dotnet-aspnet-codegenerator.exe
is there and if not click New
and add it.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