由于 ArgumentNullException,带主管的 Linux 上的 .NET Core 2.0 应用程序无法 运行

.NET Core 2.0 app on Linux with supervisor cannot run due to ArgumentNullException

我有一个 .NET Core 2.0 应用程序,我想 运行 在 Linux 服务器上。

一切都设置正确,如果我手动 运行 dotnet MyApplication.dll 然后应用程序启动并在浏览器中转到 url 工作正常。

我想使用 supervisor 自动启动应用程序,正如我在网上看到的那样。

Supervisor 已安装并配置为 运行 我的应用程序,但是 .NET 应用程序无法启动,我可以在 supervisor 错误日志中看到错误。

System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2)
   at Microsoft.DotNet.Configurer.CliFallbackFolderPathCalculator.get_DotnetUserProfileFolderPath()
   at Microsoft.DotNet.Configurer.FirstTimeUseNoticeSentinel..ctor(CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

supervisor配置如下:

[program:myapplication]
command=/usr/bin/dotnet /var/www/myapplication.mydomain/MyApplication.dll 
directory=/var/www/myapplication.mydomain
autostart=true
autorestart=true
stderr_logfile=/var/log/websites/myapplication.mydomain.err.log
stdout_logfile=/var/log/websites/myapplication.mydomain.out.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=myuser
stopsignal=INT

dotnet --info如下:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

很想让这个工作!

还在 GitHub here

上发布了这个问题

发现解决此问题的方法是将主管配置设置为以下内容:

command=/usr/bin/dotnet MyApplication.dll 
directory=/var/www/myapplication.mydomain

我猜是因为 directory 正在设置当前工作目录,dll 的路径是错误的