【发布时间】:2018-05-29 18:51:34
【问题描述】:
参考:Visual Studio Team Foundation Server 2015: 如果本地文件等于或不等于服务器上的最新版本,我如何从批处理或 Powershell 脚本中检查 TFS 源代码控制下的给定文件?
【问题讨论】:
标签: tfs
参考:Visual Studio Team Foundation Server 2015: 如果本地文件等于或不等于服务器上的最新版本,我如何从批处理或 Powershell 脚本中检查 TFS 源代码控制下的给定文件?
【问题讨论】:
标签: tfs
您可以使用 Visual Studio 附带的 tf.exe。以下是使用 PowerShell 的一些不同选项。这也可以通过一些更改批量编写。
假设如下:
# Change directory to the folder containing your file.
Set-Location "D:\MyProjects\Project1\Logic"
# File to evaluate
$file = "Program.cs"
# Using the Visual Studio 2015 Common Tools System Variable to find tf.exe
$tfExe = "$env:VS140COMNTOOLS\..\IDE\TF.exe"
1:使用get /preview,它会预览是否可以获取更新的版本。
& cmd /c "`"$tfExe`" get $file /preview"
如果是最新的结果:
All files are up to date.
如果不是最新的结果:
D:\MyProjects\Project1\Logic:
Replacing Program.cs
2:将difference /format:Brief与status一起使用,这将告诉您本地是否存在差异,但没有待处理的更改
& cmd /c "`"$tfExe`" difference $file /format:Brief"
& cmd /c "`"$tfExe`" status $file"
如果是最新的结果:
Comparing local to latest: D:\MyProjects\Project1\Logic\Program.cs
There are no pending changes.
如果不是最新的结果:
Comparing local to latest: D:\MyProjects\Project1\Logic\Program.cs
Program.cs: files differ
There are no pending changes.
3:使用info,它将显示本地变更集和服务器变更集,您可以查看它们是否不同。
& cmd /c "`"$tfExe`" info $file"
结果:
Local information:
Local path : D:\MyProjects\Project1\Logic\Program.cs
Server path: $/MyProjects/Project1/Logic/Program.cs
Changeset : 2842
Change : none
Type : file
Server information:
Server path : $/MyProjects/Project1/Logic/Program.cs
Changeset : 2845
Deletion ID : 0
Lock : none
Lock owner :
Last modified: Friday, December 15, 2017 4:32:57 PM
Type : file
File type : utf-8
Size : 2835
Info/Properties Documentation Link
还有LocalVersions,它将告诉您文件的本地变更集,以及History,它将显示文件的所有变更集。
【讨论】: