Visual Studio 找不到版本为4.0.5的包Npgsql

fruv7luv  于 2022-12-30  发布在  其他
关注(0)|答案(1)|浏览(271)

我正尝试使用MSBuild在Jenkins管道上构建解决方案。以下是各个阶段:
1.结帐
1.还原Nuget包
1.构建
下面是我的pipeline中与nuget包相关的部分的脚本:

  1. environment {
  2. nuget = "C:/nuget.exe"
  3. }
  4. stages {
  5. stage('Restore Nuget Packages') {
  6. steps {
  7. script {
  8. bat '%nuget% restore "./trunk/BALANCE/TakK_BAL.sln\"'
  9. }
  10. }
  11. }
  12. stage('Build') {
  13. steps {
  14. script {
  15. bat "\"${tool 'MSBuild'}\\MSBuild.exe\" \"./trunk/BALANCE/TakK_BAL.sln\" /p:Configuration=Debug /p:Platform=\"x64\" "
  16. }
  17. }
  18. }

checkoutrestore nuget软件包阶段成功,但我在build阶段收到错误消息,内容如下:

  1. C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\NuGet\17.0\Microsoft.NuGet.targets(198,5):
  2. error : The package Npgsql with version 4.0.5 could not be found in
  3. C:\Windows\system32\config\systemprofile\.nuget\packages\,
  4. C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages.
  5. Run a NuGet package restore to download the package.
  6. [C:\Users\ramin.bohlouli\.jenkins\workspace\BalanceTestPipeline\trunk\BALANCE\BalanceOptimaConnector\BalanceOptimaConnector.csproj]

但是,当转到:

  1. C:\Windows\system32\config\systemprofile\.nuget\packages\

并且还

  1. %userprofile%\.nuget\packages

这是默认文件夹,其中包含4.0.5版的包。
值得一提的是,我在visual studio中检查了以下路径,发现我的项目安装了npgsql 4.0.5。
工具〉NuGet包管理器〉管理解决方案的NuGet包
原因和可能的解决方案是什么?

eoxn13cs

eoxn13cs1#

发现问题并解决了它。问题是当MSBuil尝试编译时,它会查看

  1. C:\Windows\system32\config\systemprofile\.nuget\packages

它不是基于x64平台的。所以如果你使用x64的msbuildiderexe,问题就解决了。
您可以在以下路径中找到x64版本的msbuild.exe:

  1. C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64

我花了1天的时间来解决这个问题,我认为这不是我可以照顾的东西!但有时大问题有简单的答案。

相关问题