0

I'm trying to call a console app (written in c#) from a TeamCity build step. The app pulls scripts from a TFS folder and executes them on a database.

TeamCity is throwing the following error when trying to execute the app:

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

When I open a command prompt and type:

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

it runs with no problem. The error is from this code:

[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));

What does TeamCity do differently in regards to the TFS connection code causing it not run when executed by TeamCity, but run perfectly if executed manually?

user2097151
  • 131
  • 1
  • 6

0 Answers0