я наконец-то нашел способ решить эту проблему
Как узнать правильный DataspaceId:
SELECT TOP 1000 [PartitionId] ,[ProjectId],[DataspaceId],
[ProjectUri],ProjectName],[SequenceId],[IsDeleted],
[IsResolutionStateCustomized],[IsFailureTypeCustomized],[MigrationState],
[MigrationError] FROM [Tfs_DefaultCollection].[dbo].[tbl_Project]
WHERE
ProjectName = "My project witch having an error"
Конец строки в столбце [ProjectUri]
содержит уникальный идентификатор проекта (в моем случае vstfs:///Classification/TeamProject/b96fbc5b-7bf3-452b-894f-6f5b4bb801c0
)
Как узнать соответствующий DataspaceId
SELECT TOP 1000 [PartitionId]
,[DataspaceCategory]
,[DataspaceIdentifier]
,[DataspaceId]
,[DatabaseId]
,[State]
FROM [Tfs_DefaultCollection].[dbo].[tbl_Dataspace]
where DataspaceIdentifier="b96fbc5b-7bf3-452b-894f-6f5b4bb801c0"
and DataspaceCategory="Build"
Это дало мне мой IDS: 726
Проверьте, нет ли записи в таблице [Build]. [Tbl_Folder]
SELECT TOP 1000 [PartitionId]
,[DataspaceId]
,[FolderId]
,[FolderPath]
,[FolderName]
,[CreatedBy]
,[CreatedOn]
,[Description]
,[ChangedBy]
,[ChangedOn]
,[Deleted]
FROM [Tfs_DefaultCollection].[Build].[tbl_Folder]
WHERE DataspaceId=726
Если записи нет, я должен ее создать.
INSERT INTO [Build].[tbl_Folder]
([PartitionId]
,[DataspaceId]
,[FolderId]
,[FolderPath]
,[FolderName]
,[CreatedBy]
,[CreatedOn]
,[Description]
,[ChangedBy]
,[ChangedOn]
,[Deleted])
VALUES
(1
,726
,1
,''
,'\'
,'00000000-0000-0000-0000-000000000000'
,CURRENT_TIMESTAMP
,NULL
,NULL
,NULL
,0)
GO
Проверьте, нет ли записи в таблице [tbl_Counter] с этим DataspaceId
SELECT TOP 1000 [PartitionId],[DataspaceId],[CounterName],[CounterValue]
FROM [Tfs_DefaultCollection].[dbo].[tbl_Counter]
where CounterName='BuildFolderId' and DataspaceId=726
Если записи нет, я должен ее создать.
INSERT INTO [dbo].[tbl_Counter]
([PartitionId]
,[DataspaceId]
,[CounterName]
,[CounterValue])
VALUES
(1
,726
,'BuildFolderId'
,2)
GO
После этого я могу сохранить определение сборки.
Другая ошибка появляется при попытке запустить мое определение сборки:
%error="800095";%:TFSSERVER.Tfs_DefaultCollection.dbo.prc_iCounterGetNext: Counter with name %counterName="TimelineStringId";% does not exist
на основе предыдущего скрипта я вставляю новое значение в таблицу [tbl_Counter]
INSERT INTO [dbo].[tbl_Counter]
([PartitionId]
,[DataspaceId]
,[CounterName]
,[CounterValue])
VALUES
(1
,726
,'TimelineStringId'
,2)
GO
Наконец-то у меня осталась одна ошибка:
%error="800095";%:TFSSERVER.Tfs_DefaultCollection.dbo.prc_iCounterGetNext: Counter with name %counterName="TaskOrchestrationPlanId";% does not exist
так:
INSERT INTO [dbo].[tbl_Counter]
([PartitionId]
,[DataspaceId]
,[CounterName]
,[CounterValue])
VALUES
(1
,726
,'TaskOrchestrationPlanId'
,2)
GO
Я наконец смог успешно запустить определение сборки.
Надеюсь, это кому-нибудь поможет.
Я пишу SQL-скрипт в двух версиях, один для TFS2018 и один другой для TFS2015
измените переменную @projectName на ваше реальное имя проекта.
Версия TFS2018:
USE [Tfs_DefaultCollection]
GO
declare @projectUriGlobal varchar(max);
declare @projectName varchar(max);
declare @DataspaceIdentifier varchar(max);
declare @DataspaceId int;
select @projectName='MyProjectName'
select @projectUriGlobal = (select [ProjectUri] from [tbl_Project] where ProjectName=@projectName)
select @DataspaceIdentifier = (select right(@projectUriGlobal, charindex('/', reverse(@projectUriGlobal) + '/') - 1))
if not exists(select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
BEGIN
PRINT 'Création d" un enregistrement dans [tbl_Dataspace] pour le DataspaceIdentifier '+@DataspaceIdentifier;
INSERT INTO [tbl_Dataspace] VALUES (1,'Build', @DataspaceIdentifier,1,1)
END
select @DataspaceId = (select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
PRINT 'Project Name : '+@projectName;
PRINT 'Project Uri :'+ @projectUriGlobal
PRINT 'DataspaceIdentifier : '+ @DataspaceIdentifier
PRINT 'DataSpaceID : '+ CAST(@DataspaceId as varchar)
if EXISTS(SELECT TOP 1 [DataspaceId] FROM [Build].[tbl_Folder] where DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans [Build].[tbl_Folder] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' car existe déjà'
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [Build].[tbl_Folder] pour le dataspace ID '+ CAST(@DataspaceId as varchar)
INSERT INTO [Build].[tbl_Folder] ([PartitionId] ,[DataspaceId],[FolderId],[FolderPath],[FolderName],[CreatedBy],[CreatedOn],[Description],[ChangedBy],[ChangedOn],[Deleted])
VALUES (1,@DataspaceId,1,'','\','00000000-0000-0000-0000-000000000000',CURRENT_TIMESTAMP,NULL ,NULL,NULL,0)
END
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='BuildFolderId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'BuildFolderId',2)
END
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='TimelineStringId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TimelineStringId',2)
END
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='TaskOrchestrationPlanId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TaskOrchestrationPlanId',2)
END
И версия для TFS2015 будет
USE [Tfs_DefaultCollection]
GO
declare @projectUriGlobal varchar(max);
declare @projectName varchar(max);
declare @DataspaceIdentifier varchar(max);
declare @DataspaceId int;
select @projectName='MyProjectName'
select @projectUriGlobal = (select [ProjectUri] from [tbl_Project] where ProjectName=@projectName)
select @DataspaceIdentifier = (select right(@projectUriGlobal, charindex('/', reverse(@projectUriGlobal) + '/') - 1))
if not exists(select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
BEGIN
PRINT 'Création d" un enregistrement dans [tbl_Dataspace] pour le DataspaceIdentifier '+@DataspaceIdentifier;
INSERT INTO [tbl_Dataspace] VALUES (1,'Build', @DataspaceIdentifier,1,1)
END
select @DataspaceId = (select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
PRINT 'Project Name : '+@projectName;
PRINT 'Project Uri :'+ @projectUriGlobal
PRINT 'DataspaceIdentifier : '+ @DataspaceIdentifier
PRINT 'DataSpaceID : '+ CAST(@DataspaceId as varchar)
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='BuildFolderId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'BuildFolderId',2)
END
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='TimelineStringId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TimelineStringId',2)
END
if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter] where CounterName='TaskOrchestrationPlanId' and DataspaceId=@DataspaceId)
BEGIN
PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId car existe déjà';
END
ELSE
BEGIN
PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId';
INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TaskOrchestrationPlanId',2)
END