如何签入TFS中的文件,该文件已通过签入要求签出进行编辑

问题描述 投票:1回答:1

下面是从TFS检出文件的代码,在检出文件后,更新的文件被复制到我需要签到TFS的本地路径。在签入时,我需要在“相关工作项”标题下的“工作项目ID”选项中添加值,以及注释和其他选项。

 $TFSCheckoutExe="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe"
    #File to be checked-out in TFS
    $TFSFilePath="$/Intell/Installscript/Utility Scripts/powershells/DI_UTC_Test.PS1"

    #This file needs to be checked-in in TFS after some changes are done.
    $Localfilepath="C:\Intell\Installscript\Utility Scripts\powershells\DI_UTC_Test.PS1"

    $demo="C:\demo\files to check in"

    #Checking out file
    &$TFSCheckoutExe checkout $TFSFilePath | Out-Null 

    #Copying the updated file to the mapped path of the file checked out.
    Copy-Item -path $demo -Destination "$Localfilepath" -Force

    #How to Checkin the copied file in TFS
    $ItemPath = "C:\Intell\Installscript\Utility Scripts\powershells\DI_UTC_Test.PS1"


    #Checkin the file by passing the required details which are require for checkin in any file.
    $null = & $TFSCheckoutExe checkin $Itempath /comment:"Added POC file" /notes:"Code reviewer=None ; Unit Testing=N/A ; Build Details=N/A" /Related Work Items:"Add Work Item by ID=86165"

上面的代码在“/相关工作项:”添加工作项目ID = 81165“的最后一行给出错误,我想在办理登机手续时添加,这只是PBI编号。

以下是执行脚本时发生的错误:

    TF.exe : TF10139: The following check-in policies have not been satisfied:
At C:\Demo\powershell scripts\demo1.ps1:17 char:9
+ $null = & $TFSCheckoutExe checkin $Itempath /comment:"Added POC file" /notes:"Co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (TF10139: The fo...been satisfied::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  You must associate this check-in with one or more work items.
powershell tfs tfs2013
1个回答
1
投票

不幸的是,在VS中使用Team Explorer的TFVC,“tf.exe checkin”不支持从命令行关联工作项。没有参数:/相关工作项。有关详细信息,请参阅Checkin command

此处还有一个问题:https://github.com/Microsoft/vsts-vscode/issues/191

但是,您可以尝试使用Team Explorer Everywhere和以下命令将一个或多个工作项与变更集关联:

tf checkin ItemSpec -associate:WorkItemIds

有关详细信息,请参阅Associate Work Items with Changesets (Team Explorer Everywhere)

也是这个帖子供你参考:Link command line tf checkin to work item

© www.soinside.com 2019 - 2024. All rights reserved.