从TeamCity运行控制台应用程序失败

时间:2014-07-10 01:47:07

标签: c# tfs console-application tfs2012 teamcity-8.0

我正在尝试从TeamCity构建步骤调用控制台应用程序(用c#编写)。该应用程序从TFS文件夹中提取脚本并在数据库上执行它们。

TeamCity在尝试执行应用程序时抛出以下错误:

Starting:  C:\Utilities\DatabaseUpdateAgent\DatabaseUpdateAgent\bin\Debug\DatabaseUpdateAgent.exe Main
[Step 2/2] in directory: C:\BuildAgent\work\aeaa47afdd4f1378
[Step 2/2] Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
[Step 2/2]    at Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(RegisteredProjectCollection projectCollection)
[Step 2/2]    at DatabaseUpdateAgent.DatabaseUpdateWorker.UpdateScripts(ConnectionStringSettings connection) in c:\Utilities\DatabaseUpdateAgent\DatabaseUpdateAgent\DatabaseUpdateWorker.cs:line 63
[Step 2/2]    at DatabaseUpdateAgent.DatabaseUpdateWorker.UpdateDatabase() in c:\Utilities\DatabaseUpdateAgent\DatabaseUpdateAgent\DatabaseUpdateWorker.cs:line 50
[Step 2/2]    at DatabaseUpdateAgent.Program.Main(String[] args) in c:\Utilities\DatabaseUpdateAgent\DatabaseUpdateAgent\Program.cs:line 19
[Step 2/2] Process exited with code 255

当我打开命令提示符并输入:

C:\ Utilities \ DatabaseUpdateAgent \ DatabaseUpdateAgent \ bin \ Debug \ DatabaseUpdateAgent.exe Main

它运行没有问题。错误来自此代码:

[Line 62] var server = RegisteredTfsConnections.GetProjectCollection(new Uri("http://tfsserver:8080/tfs/DefaultCollection"));
[Line 63] var projects = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(server);
[Line 64] var versionControl = (VersionControlServer)projects.GetService(typeof(VersionControlServer));

TeamCity在TFS连接代码方面做了哪些不同的事情,导致它在TeamCity执行时不运行,但如果手动执行则运行良好?

0 个答案:

没有答案