通过PowerShell在TFS上签出/签入文件

7

我希望使用PowerShell自动化编辑.csproj文件并将其签出和签入到TFS。我只需要将单个文件更改为待处理状态并进行签入。

有人知道如何做到这一点吗?

2个回答

8

我曾经遇到和你一样的痛苦,最终找到了正确的方法。这里给你。

#Load the TFS powershell
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
# the filePath should be in the format like C:\MyFodler\MyFile.txt
Add-TfsPendingChange -Edit -Item $filepath -Verbose -ErrorAction SilentlyContinue -wa 0
# Check in the file after changes.
New-TfsChangeset -Item $filepath -Verbose -Comment "Comment Here" -Override true

7

您可以使用New-TfsChangeSet cmdlet进行签入,使用Add-TfsPendingChange -Edit cmdlet进行签出。

要获取这些cmdlets,您必须安装Microsoft Team Foundation Server 2010 Power Tools。


1
你有该 cmdlet 的文档链接吗?我已安装了 Power Tools 并更新了 PowerGUI,但它们目前还没有出现。 - StuperUser
1
@StuperUser:使用必应搜索,我找到了https://blogs.msdn.com/b/bharry/archive/2008/10/01/preview-of-the-next-tfs-power-tools-release.aspx?Redirected=true和https://rkeithhill.wordpress.com/2008/11/11/team-foundation-powershell-pssnapin-in-october-team-foundation-power-tools-drop/。 - PVitt
要在 PowerShell 会话或脚本中使用 cmdlet,您必须首先将 snap-in 添加到环境中:add-pssnapin Microsoft.TeamFoundation.PowerShell - herzbube

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接