Powershell 如何在TFS中签入已签出以进行编辑的文件及其签入要求

Powershell 如何在TFS中签入已签出以进行编辑的文件及其签入要求,powershell,tfs,Powershell,Tfs,下面是从TFS签出文件的代码,签出后,将在本地路径复制更新的文件,我需要将其签入TFS。在签入时,我需要在相关工作项标题下的WorkItem by ID选项中添加值,以及注释和其他选项 $TFSCheckoutExe="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe" #File to be checked-out in TFS $TFSFilePath="$/Intell/Insta

下面是从TFS签出文件的代码,签出后,将在本地路径复制更新的文件,我需要将其签入TFS。在签入时,我需要在相关工作项标题下的WorkItem by 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"
上面的代码在“/相关工作项”的最后一行给出了错误:“addworkitembyid=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.

不幸的是,对于VS中带有团队资源管理器的TFVC,“
tf.exe checkin
”不支持从命令行关联工作项。没有参数:/相关工作项。 有关详细信息,请参阅

这里还跟踪了一个问题:

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

tf checkin ItemSpec -associate:WorkItemIds
有关详细信息,请参阅


还有这个线程供您参考:

相关的工作项不需要Id列表吗?为什么要传递文本字符串“按Id添加工作项”=“在那里?没有,在签入时,在将任何内容签入TFS之前,我需要填写一些必需的详细信息。例如,代码审阅者姓名、单元测试等。就像这样,我想输入PBI号。当我们手动签入时,单击Add Work Item by ID选项,在相关工作项:标题下填写PBI号,但在这里我想通过脚本传递值。现在对于没有WorkItemId的签入,我使用/override参数,至少它允许我签入。