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 主

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

[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 执行时无法运行,但如果手动执行则可以完美运行?

4

0 回答 0