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

时间:2017-12-05 11:22:47

标签: powershell tfs tfs2013

下面是从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.

1 个答案:

答案 0 :(得分:1)

不幸的是,在VS中使用团队资源管理器的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

相关问题