我正在尝试在jenkins上使用.NET Core CLI命令dotnet restore . 当我以Jenkins使用的用户身份登录时,使用解决方案导航到工作区文件夹,它可以正常工作 . 但是,当我创建一个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任务发送到ECHO%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):错误:值不能为空 . [D:\ Workspaces \ WEBCORE \ WebStarter.sln] C:\ Program Files \ dotnet \ sdk \ 1.0.4 \ NuGet.targets(97,5):错误:参数名称:path1 [D:\ Workspaces \ WEBCORE \ WebStarter的.sln]
看起来像一个类似的问题 . 需要为dotnet还原设置哪些环境变量才能运行?
1 回答
Bamboo Windows代理程序也会出现同样的问题 . 解决方案涉及设置以下环境变量 . 在dotnet核心SDK v2.1.302上测试 .