加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 通过tf.exe确定TFS工作区的本地路径

发布时间:2020-12-14 02:49:29 所属栏目:Windows 来源:网络整理
导读:我正在使用批处理脚本来获取特定项目的最新版本.此脚本仅运行tf.exe并获取某些二进制文件的最新版本.一切正常,但我想将下载文件的属性更改为可写(通过嘲笑这些文件是只读的).为此我想确定文件的本地路径并使用批处理中的attrib-command. tf.exe workfold [工
我正在使用批处理脚本来获取特定项目的最新版本.此脚本仅运行tf.exe并获取某些二进制文件的最新版本.一切正常,但我想将下载文件的属性更改为可写(通过嘲笑这些文件是只读的).为此我想确定文件的本地路径并使用批处理中的attrib-command.

tf.exe workfold [工作区]向我展示了某种列表中的本地路径,但它会更容易,如果它只显示我想要的东西,那么我可以使用提示.到现在为止它看起来像这样:

tf.exe workfold [Workspace]

=======================================

Arbeitsbereich: XYZ-xxxxxx (Username)

Auflistung: TFS-URL

[Workspace]:  C:xxxTFSxxx

是否可以仅确定TFS工作区的本地路径映射,以便我可以使用attrib-command的提示而无需解析?

解决方法

以下(原油!!!)概念怎么样?

function Get-TfsWorkfold([string]$TfsCollection,[string]$TfsWorkspace)
{
    $TfExePath = "${env:ProgramFiles(x86)}Microsoft Visual Studio 10.0Common7IDETF.exe"
    Write-Output "Getting workfold for '$TfsCollection'->'$TfsWorkspace'..."
    Push-Location $LocalPath
    & "$TfExePath" workfold /collection:$TfsCollection /workspace:$TfsWorkspace
}

function Handle-Path()
{
    param([Parameter(ValueFromPipeline=$true,Position=0)] [string] $line)
    $startIndex = $line.IndexOf(': ') + 2;
    $correctedLine = $line.subString($startIndex,$line.length - $startIndex - 1);
    Write-Output $correctedLine;
    Get-ChildItem $correctedLine
}

Get-TfsWorkfold "{serverAndcollection}"  "{workspace}" > c:temptest.txt
Select-String c:temptest.txt -pattern:': ' | Select-Object Line | Handle-Path

Handle-Path中的最后一行是您可以随心所欲地重写的示例.它是PowerShell但它应该按你的意愿工作.

替换{serverAndcollection}和{workspace}.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读