詹金斯没有找到一个nuget包

Fri*_*ren 12 msbuild continuous-integration nuget jenkins

我正在设置一个Jenkins CI服务器.我迈出了正确运行的第一步:

nuget restore -NonInteractive  -ConfigFile Nuget.config -Verbosity Detailed -NoCache
Run Code Online (Sandbox Code Playgroud)

这工作正常,但当我想编译应用程序:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
Run Code Online (Sandbox Code Playgroud)

${WorkSpace}\src\Weather.App.csproj 抛出此错误:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : The package HockeySDK.Core with version 4.1.6 could not be found in C:\WINDOWS\system32\config\systemprofile\.nuget\packages\. Run a NuGet package restore to download the package. [C:\Program Files (x86)\Jenkins\workspace\MyApp\Weather\Weather.App.csproj]
Run Code Online (Sandbox Code Playgroud)

奇怪的是,曲棍球包明显存在于路径中: 在此输入图像描述

如果我在VS2017本地项目中运行相同的命令,一切运行顺利.但jenkins服务器(在我的同一台机器上)并没有正确构建它.

有任何想法吗?谢谢

And*_*ray 1

这就是窍门。

  1. 将 nuget.exe 放在构建服务器上的某个位置。

  2. 确保 nuget.exe 在 PATH 环境变量中。

  3. 重新启动 Jenkins,以便它获取更新的 PATH 环境变量

  4. 将 NuGet 升级到最新版本

    nuget.exe update --self

在 Jenkins 作业中,针对 MSBUILD 调用重建将无法成功恢复 nuget 包

在 MSBUILD Clean 之后、MSBUILD Rebuild 之前添加 Windows 批处理步骤,如下所示:

nuget restore <your_solution_file>.sln

解决方案文件的路径是相对于工作区的。

这将按照您的预期创建软件包目录。