问题
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:
- Permissions! - My server always runs as admin.
- 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:
- Go to Control Panel -> System and Security -> Administrative Tools
- Click on the Services shortcut.
- Right click on the Jenkins service and select Properties.
- Navigate to the Log On tab.
- Click on run as this user and fill in your credentials.
- Restart Jenkins.
Works like a charm!
来源:https://stackoverflow.com/questions/25523964/msbuild-jenkins-nuget-integration