linux dotnet run失败,`Unhandled Exception:System.ArgumentNullException:使用启动脚本运行`dotnet run`时,值不能为空.错误...

在服务器启动或重启时,通过init.d脚本执行的dotnet应用程序出现错误。脚本中,dotnet run --configuration Release命令无法正常工作,抛出System.ArgumentNullException,指出path1参数不能为空。该问题只在服务器启动时发生,手动运行脚本则没有问题。错误发生在NuGet包解析过程中,可能是路径配置或依赖问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我正在尝试使用dotnet run --configuration Release系统服务器Startup/Reboot 运行一个dotnet应用程序.我正在使用init.d脚本来实现同样的目标.

我的启动脚本位于/etc/init.d/myscript包含以下内容:

#!/bin/sh

/home/user/myscripts/botScript.sh

内容botScript.sh:

#!/bin/bash

cd /home/user/bot/

nohup dotnet run --configuration Release &

当我的服务器启动或重新启动时,启动脚本会被执行但dotnet run不起作用.我收到以下错误:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.

Parameter name: path1

at System.IO.Path.Combine(String path1, String path2, String path3)

at Microsoft.DotNet.ProjectModel.Resolution.PackageDependencyProvider.ResolvePackagesPath(String rootDirectory, GlobalSettings settings)

at Microsoft.DotNet.Configurer.NuGetCacheSentinel.get_NuGetCachePath()

at Microsoft.DotNet.Configurer.NuGetCacheSentinel.Exists()

at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()

at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()

at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)

at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)

at Microsoft.DotNet.Cli.Program.Main(String[] args)

但是所有其他命令在该脚本中工作正常,甚至只是运行也dotnet很好(我已经检查过).这只是dotnet run不起作用.

是的,但是当我运行脚本时,myscript以及botScript.sh在登录到我的服务器之后,它都可以正常工作而没有任何错误.

拜托,任何人都可以帮我解决这个问题吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值