Jenkins 找不到 nuget 包

标签 jenkins msbuild continuous-integration nuget

我正在设置 Jenkins CI 服务器。我得到了正确运行的第一步:

nuget restore -NonInteractive  -ConfigFile Nuget.config -Verbosity Detailed -NoCache

这工作正常,但是当我想用以下内容编译应用程序时:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe

${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]

奇怪的是,Hockey 包显然存在于路径中: enter image description here

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

有什么想法吗?谢谢

最佳答案

这就是技巧。

  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

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

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

关于Jenkins 找不到 nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43276107/

相关文章:

.net - 使用 MSBuild 为 VS 2003、VS 2005 和 VS 2010 构建 VS .NET 项目

c# - PackageReference 未将 dll 复制到使用者(测试)项目输出,ExcludeAssets = "runtime"且 PrivateAssets = "none"

Github 操作 : Post comment to PR workflow that triggered the current workflow

jenkins - Coverity & Jenkins : Howto analyse newly committed code ONLY

docker - 在 Jenkins 中使用 docker 的最佳实践?

git - 从 MSBuild 获取 Git Long Hash

git - 让 buildbot 轮询 git 存储库以获取新提交?

jenkins - 从 Jenkins 文件登录到 Openshift

ios - 为 iOS 设置 Jenkins 时出错

heroku - Travis CI 无法识别重命名的存储库