MSBuild - Jenkins - Nuget integration

不打扰是莪最后的温柔 提交于 2020-02-22 08:49:43

问题


We are experiencing some weird behavior using Jenkins and MSBuild. When manually typing into a command line to build a build.xml project:

msbuild build.xml /T:Package /P:PublishProfile=Test /P:Platform="AnyCPU" 
                  /P:VisualStudioVersion=12.0

The build process works exactly as expected (build, packaging, etc.)
However, if I am using Jenkins to do exactly this - that is - open a command line and run this exact command, I get an error saying:

The command ""..\.nuget\NuGet.exe" install 
"C:\Jenkins\jobs\.....\workspace\MYPROJECT\packages.config" 
-source ""  -NonInteractive -RequireConsent -solutionDir "..\ "" exited with code 1

Even if I am using the built-in jenkins plugin to run the command (regardless which parma combination I use), it still doesn't.
I know two of the following sounds like a solution, but they don't work:

  1. Permissions! - My server always runs as admin.
  2. Enabling package restoring on NuGet from VS - Already did!

Any idea will be great!!!


回答1:


Here is the answer, it took a long time to solve, and thanks to @adarshr I came to realize the problem is because of the difference between the Jenkins runner's user (i.e the jenkins Service) and my user. To resolve this issue I've made Jenkins running as the same user and all good!

Step by step:

  1. Go to Control Panel -> System and Security -> Administrative Tools
  2. Click on the Services shortcut.
  3. Right click on the Jenkins service and select Properties.
  4. Navigate to the Log On tab.
  5. Click on run as this user and fill in your credentials.
  6. Restart Jenkins.

Works like a charm!



来源:https://stackoverflow.com/questions/25523964/msbuild-jenkins-nuget-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!