我正尝试使用MSBuild在Jenkins管道上构建解决方案。以下是各个阶段:
1.结帐
1.还原Nuget包
1.构建
下面是我的pipeline中与nuget包相关的部分的脚本:
environment {
nuget = "C:/nuget.exe"
}
stages {
stage('Restore Nuget Packages') {
steps {
script {
bat '%nuget% restore "./trunk/BALANCE/TakK_BAL.sln\"'
}
}
}
stage('Build') {
steps {
script {
bat "\"${tool 'MSBuild'}\\MSBuild.exe\" \"./trunk/BALANCE/TakK_BAL.sln\" /p:Configuration=Debug /p:Platform=\"x64\" "
}
}
}
checkout和restore nuget软件包阶段成功,但我在build阶段收到错误消息,内容如下:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\NuGet\17.0\Microsoft.NuGet.targets(198,5):
error : The package Npgsql with version 4.0.5 could not be found in
C:\Windows\system32\config\systemprofile\.nuget\packages\,
C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages.
Run a NuGet package restore to download the package.
[C:\Users\ramin.bohlouli\.jenkins\workspace\BalanceTestPipeline\trunk\BALANCE\BalanceOptimaConnector\BalanceOptimaConnector.csproj]
但是,当转到:
C:\Windows\system32\config\systemprofile\.nuget\packages\
并且还
%userprofile%\.nuget\packages
这是默认文件夹,其中包含4.0.5版的包。
值得一提的是,我在visual studio中检查了以下路径,发现我的项目安装了npgsql 4.0.5。
工具〉NuGet包管理器〉管理解决方案的NuGet包
原因和可能的解决方案是什么?
1条答案
按热度按时间eoxn13cs1#
发现问题并解决了它。问题是当MSBuil尝试编译时,它会查看
它不是基于x64平台的。所以如果你使用x64的msbuildiderexe,问题就解决了。
您可以在以下路径中找到x64版本的msbuild.exe:
我花了1天的时间来解决这个问题,我认为这不是我可以照顾的东西!但有时大问题有简单的答案。