.NET 5.0 Webjob no longer starting with self-contained build

Viewed 935

I switched my builds to self-contained because of .NET 5.0. I know there is a preview runtime, but I don't want to bet on this for my production environment. I encountered situations where the preview runtime was switched back unintentionally (e.g. scale-out).

dotnet publish --configuration release --self-contained true --runtime win-x64

After doing a self-contained build, my webjob no longer started. While looking at the logs, I just found this:

[12/22/2020 16:36:05 > 62427f: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
[12/22/2020 16:36:05 > 62427f: SYS INFO] Status changed to Starting
[12/22/2020 16:36:05 > 62427f: SYS INFO] WebJob singleton setting is False
[12/22/2020 16:36:07 > 62427f: SYS INFO] Run script 'createdump.exe' with script host - 'WindowsScriptHost'
[12/22/2020 16:36:07 > 62427f: SYS INFO] Status changed to Running
[12/22/2020 16:36:35 > 62427f: ERR ] createdump [options] pid
[12/22/2020 16:36:35 > 62427f: ERR ] -f, --name - dump path and file name. The default is '%TEMP%\dump.%p.dmp'. These specifiers are substituted with following values:
[12/22/2020 16:36:35 > 62427f: ERR ]    %p  PID of dumped process.
[12/22/2020 16:36:35 > 62427f: ERR ]    %e  The process executable filename.
[12/22/2020 16:36:35 > 62427f: ERR ]    %h  Hostname return by gethostname().
[12/22/2020 16:36:35 > 62427f: ERR ]    %t  Time of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
[12/22/2020 16:36:35 > 62427f: ERR ] -n, --normal - create minidump.
[12/22/2020 16:36:35 > 62427f: ERR ] -h, --withheap - create minidump with heap (default).
[12/22/2020 16:36:35 > 62427f: ERR ] -t, --triage - create triage minidump.
[12/22/2020 16:36:35 > 62427f: ERR ] -u, --full - create full core dump.
[12/22/2020 16:36:35 > 62427f: ERR ] -d, --diag - enable diagnostic messages.
[12/22/2020 16:36:36 > 62427f: SYS ERR ] Job failed due to exit code -1
[12/22/2020 16:36:36 > 62427f: SYS INFO] Process went down, waiting for 60 seconds
[12/22/2020 16:36:36 > 62427f: SYS INFO] Status changed to PendingRestart

What does this createdump log output mean?

1 Answers

When doing a self-contained build, your build output folder will include a createdump.exe file. When deploying the WebJob to App Service, it will now pick this .exe instead of your WebJob. This is why the log shows the CLI output of createdump.exe.

The fix: create a run.cmd file that contains only the name of your mywebjob.exe.

https://github.com/projectkudu/kudu/wiki/WebJobs

  • Per file type we look first for a file named: run.{file type extension} (for example run.cmd or run.exe).
  • If it doesn't exists for all file types, we'll then look for the first file with a supported file type extension.
  • The order of file types extension used is: .cmd, .bat, .exe, .ps1, .sh, .php, .py, .js.
  • The recommended script file to have in your job directory is: run.cmd.
  • Note: We'll only look for a script under the root directory of that job (not under sub directories of it).
  • Note: make sure .bat/.cmd files don't include the UTF-8 BOM (inserted by some editors such as Visual Studio by default), which can break things!

PS: You cannot simply delete the createdump.exe, because your app will not start without it.

Related