2

我们在使用 Jenkins 和 MSBuild 时遇到了一些奇怪的行为。手动输入命令行以构建 build.xml 项目时:

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

构建过程完全按预期工作(构建、打包等)
但是,如果我使用 Jenkins 来执行此操作 - 也就是说 - 打开命令行并运行这个确切的命令,我会收到一条错误消息

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

即使我使用内置的 jenkins 插件来运行命令(无论我使用哪种 parma 组合),它仍然没有。
我知道以下两个听起来像是一个解决方案,但它们不起作用:

  1. 权限!- 我的服务器始终以管理员身份运行。
  2. 从 VS 在 NuGet 上启用包还原 - 已经做到了!

任何想法都会很棒!!!

4

1 回答 1

5

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.

enter image description here

Works like a charm!

于 2014-08-27T12:27:20.017 回答