DotNet CLI build fails for VS .NET Core project when run from TFS 2015 build agent

喜欢而已 提交于 2019-12-23 23:57:19

问题


Problem

The command dotnet build ... fails when run from TFS 2015 build agent with the following errors:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : Object reference not set to an instance of an object.

C:\Program Files\dotnet\dotnet.exe compile-csc @(path to dotnet-compile.rsp) returned Exit Code 1


Steps to Reproduce

  1. Create an ASP.NET Core 1.0 web application with Visual Studio 2015 (Tools Preview 2).
  2. Commit solution to TFS 2015 team project.
  3. Configure a TFS 2015 Windows build agent running as NT AUTHORITY\NETWORK SERVICE (the default).
  4. Trigger a build using the MSBuild or VSBuild task to build the solution.
  5. Build fails with the errors above.

Environment

  • Windows Server 2012 R2
  • Team Foundation Server 2015 Update 2
  • Visual Studio 2015 Community Update 3
  • Microsoft .NET Core 1.0.0 - SDK Preview 2 (x64)
  • Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2
  • dotnet --version: 1.0.0-preview2-003121
  • TFS Build Agent Version: 14.95.25122.0

回答1:


Visual Studio needs to be launched once on the machine running the build agent using the service account assigned to the build agent.

For example, to launch Visual Studio as NT AUTHORITY\NETWORK SERVICE:

psexec -i -u "NT AUTHORITY\NETWORK SERVICE" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"

(PsExec can be downloaded here.)

The login to Visual Studio Online can be skipped.

After Visual Studio launches, the TFS build will succeed.


Edit 1

After further investigation, it appears you also need to create a new .NET Core Web Application project (File -> New -> Project...) and build it, once Visual Studio starts.



来源:https://stackoverflow.com/questions/38173700/dotnet-cli-build-fails-for-vs-net-core-project-when-run-from-tfs-2015-build-age

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