I tried to deploy the ASP.NET Core 2 website to Ubuntu following https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&tabs=aspnetcore2x.
However, it throws an exception:
Failed at step CHDIR spawning "/usr/bin/dotnet": No such file or directory from the file
The error is from this file
[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/var/aspnetcore/hellomvc
ExecStart=/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
However, the command /usr/bin/dotnet exists, and it's fine when I ran
/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
I googled it, but the best answer I found suggested it's related to the user www-data. Still I could not figure out what's wrong. Any help would be greatly appreciated.
Look at for the WorkingDirectory path, cd to the path directly. In my case, WorkingDirectory path folder was missing and when I created it manually it started working.
Hope this help.
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