In some instances, builds hang and never go to a valid final states (success, failed, etc.). When you try to delete those builds, the error pops up saing it is still in progress and could not be deleted.

To fix this, you have to find those records and manually fix it from the database records.

1. Find the records

SELECT * FROM [Tfs_TeamProjectCollection].[dbo].[tbl_Build]
WHERE DefinitionId = xxx

SELECT * FROM [Tfs_TeamProjectCollection].[dbo].[tbl_BuildQueue]
WHERE BuildId = xxxxx

2. Mark those builds as deleted

UPDATE
[Tfs_TeamProjectCollection].[dbo].[tbl_Build]
SET
BuildStatus = 2,
CompilationStatus = 2,
Deleted = 1
WHERE
DefinitionId = xxx

UPDATE
[Tfs_LS].[dbo].[tbl_BuildQueue]
SET
[Tfs_LS].[dbo].[tbl_BuildQueue].[Status] = 16,
[Tfs_LS].[dbo].[tbl_BuildQueue].[Deleted] = 0
WHERE
BuildId = xxxxx

3. Then you can delete the build definition from Visual Studio

Advertisements