Rotativa.AspNetCore icon indicating copy to clipboard operation
Rotativa.AspNetCore copied to clipboard

How to Run on Azure Linux app

Open nyghtrocker opened this issue 4 years ago • 4 comments

I'm getting this exception after publish to azure Linux app using .net core 3.1

System.Exception: run-detectors: unable to find an interpreter for /home/site/wwwroot/wwwroot/Rotativa/linux/wkhtmltopdf

at FIMS.Web.Controllers.InvoiceController.DownloadPaySlip(Int64 invoiceId) in d:\a\1\s\src\FIMS.Web\Controllers\InvoiceController.cs:line 250 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

nyghtrocker avatar Jun 07 '20 06:06 nyghtrocker

@nyghtrocker Did you ever get a fix for this? It works fine on my local but on Linux server i'm getting.

Win32Exception: No such file or directory System.Diagnostics.Process.ForkAndExecProcess(string filename, string[] argv, string[] envp, string cwd, bool redirectStdin, bool redirectStdout, bool redirectStderr, bool setCredentials, uint userId, uint groupId, uint[] groups, out int stdinFd, out int stdoutFd, out int stderrFd, bool usesTerminal, bool throwOnNoExec) System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) System.Diagnostics.Process.Start() Rotativa.AspNetCore.WkhtmlDriver.Convert(string wkhtmlPath, string switches, string html, string wkhtmlExe) Rotativa.AspNetCore.WkhtmltopdfDriver.ConvertHtml(string wkhtmltopdfPath, string switches, string html) Rotativa.AspNetCore.ViewAsPdf.CallTheDriver(ActionContext context) Rotativa.AspNetCore.AsResultBase.BuildFile(ActionContext context) Rotativa.AspNetCore.AsResultBase.ExecuteResultAsync(ActionContext context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

william-finance-ni avatar Dec 03 '20 10:12 william-finance-ni

Hi, I can't find solution for this problem. I wrote one small separate Api and hosted it on windows machine and make a http request from my app to this api. windows hosted api return the result as byte array or base 64 string and then use this result.

nyghtrocker avatar Dec 03 '20 20:12 nyghtrocker

Rotativa intregation working fine to me after configure de linux environment following this steps:

1 - Access the linux environment with SSH

2 - Update the packages

apt-get update

3 - Install sudo

apt-get -y install sudo

4 - Try install the package .deb

dpkg -i wkhtmltox.deb

5 - If the wkhtmltox.deb instalation fail, install the missing dependencies

apt-get -f install

6 - Try install the package .deb again

dpkg -i wkhtmltox.deb

7 - After success instalation move the file to your Rotativa folder.

sudo cp /usr/local/bin/wkhtmltopdf ~/site/wwwroot/wwwroot/Rotativa

willpower18 avatar Oct 13 '22 11:10 willpower18

Create a file called install-tools.sh with the following content:

#!/bin/sh
apt update
apt -y install wget
### Debian 10 ### (change to your operating system)
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb
apt install -f -y ./wkhtmltox_0.12.6-1.buster_amd64.deb
### Copy files ###
cp -f /usr/local/bin/wkhtmltopdf ~/site/wwwroot/wwwroot/Rotativa
cp -f /usr/local/bin/wkhtmltoimage ~/site/wwwroot/wwwroot/Rotativa

Create a file called startup.sh with the following content:

#!/bin/sh
sh ./install-tools.sh &
dotnet PUT-YOUR-PROJECT-HERE.dll

change application execution to ./startup.sh.
Every time a new deployment occurs, the packages will be installed again.

RGalli avatar Oct 20 '23 22:10 RGalli