[英]The package Npgsql with version 4.0.5 could not be found
I am trying to build a solution on my jenkins pipeline using MSBuild. Here are the stages:我正在尝试使用 MSBuild 在我的 jenkins 管道上构建解决方案。以下是阶段:
Here is the script of my pipeline for the part related to nuget packages:这是我的管道脚本,用于与 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\" "
}
}
}
The checkout and restore nuget package stages are successful but I am getting an error in the build stage saying: checkout和restore nuget package阶段是成功的,但我在构建阶段收到错误消息:
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]
However, when going to:然而,当去:
C:\Windows\system32\config\systemprofile\.nuget\packages\
and also并且
%userprofile%\.nuget\packages
which is the default folder, the package with the version 4.0.5 is there.这是默认文件夹,其中包含版本 4.0.5 的 package。
It's worth mentioning that I checked inside the following path in visual studio and saw that for my project the npgsql 4.0.5 was installed.值得一提的是,我在 visual studio 中检查了以下路径,发现我的项目安装了 npgsql 4.0.5。
tools > NuGet Package Manager > Manage NuGet packages for solution tools > NuGet Package Manager > Manage NuGet packages for solution
What could be the reason and the possible solution?可能是什么原因和可能的解决方案?
Found the problem and solved it.找到问题并解决了。 The problem is that when MSBuil tries to compile, it looks into问题是当 MSBuil 尝试编译时,它会查看
C:\Windows\system32\config\systemprofile\.nuget\packages
which is not based on a x64 platform.它不是基于 x64 平台。 So if you use msbuild.exe which is for x64, the problem is solved.所以如果你使用 x64 的 msbuild.exe,问题就解决了。
You can find the x64 version of msbuild.exe in the following path: x64版本的msbuild.exe可以在以下路径找到:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64
I spend 1 day on fixing this problem and I thought it's not something that I can take care of.我花了 1 天时间解决这个问题,我认为这不是我能解决的问题。 but sometimes big problems have simple answers.但有时大问题有简单的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.