Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.NET Core dotnet还原在jenkins上失败,出现System.ArgumentNullException_Jenkins_.net Core - Fatal编程技术网

.NET Core dotnet还原在jenkins上失败,出现System.ArgumentNullException

.NET Core dotnet还原在jenkins上失败,出现System.ArgumentNullException,jenkins,.net-core,Jenkins,.net Core,我正在尝试使用.NET Core CLI命令 网络还原 关于詹金斯。当我以Jenkins用户的身份登录时,导航到包含解决方案的workspace文件夹,它就可以工作了。然而,当我创建Jenkins作业并添加构建步骤以执行命令时,我得到 Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: path1 at System.IO.Path.Combine(String p

我正在尝试使用.NET Core CLI命令 网络还原 关于詹金斯。当我以Jenkins用户的身份登录时,导航到包含解决方案的workspace文件夹,它就可以工作了。然而,当我创建Jenkins作业并添加构建步骤以执行命令时,我得到

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder)
   at NuGet.Configuration.SettingsUtility.GetHttpCacheFolder()
   at NuGet.Configuration.NuGetPathContext.Create(ISettings 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)
奇怪的是:

1) 这与我将参数“-packages C:\test”传递给dotnet restore时的失败方式相同

2) callstack表示它认为自己是第一次运行和配置.NET Core。尽管之前已经以此用户身份运行了它,但仍然存在这种情况

3) 我已经读到,默认情况下,dotnet restore会将包还原到%USERPROFILE%目录。奇怪的是,当我让jenkins任务回显%USERPROFILE%时,它返回的是C:\Users\Default目录,而不是正确的用户目录。因此,它没有拾取环境变量%USERPROFILE%

为什么Jenkins认为它每次都是第一次配置.NET Core,为什么它没有正确的用户目录,并且有没有办法解决这些问题来运行.NET Core CLI


更新:我深入研究了nuget代码,发现它试图查找LOCALAPPDATA。我在詹金斯设置了这个,但现在我得到了错误

C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5):错误:值不能为null。[D:\workspace\WEBCORE\WebStarter.sln] C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5):错误:参数名称:path1[D:\workspace\WEBCORE\WebStarter.sln]


看起来是类似的问题。要运行dotnet restore,需要设置哪些环境变量?

同样的问题也发生在Windows代理上。解决方案包括设置以下环境变量。在dotnet core SDK v2.1.302上测试

    set HOMEPATH=%USERPROFILE%
    set APPDATA=%USERPROFILE%\AppData\Roaming
    set LOCALAPPDATA=%USERPROFILE%\AppData\Local

最后,我通过使用SET提取所有Windows环境变量来解决这个问题。然后我创建了一个批处理脚本来设置它们,并在调用dotnetrestore之前从Jenkins作业调用了这个脚本。