seb*_*n87 5 windows tfs cmd batch-file
我正在使用批处理脚本来获取特定项目的最新版本.此脚本仅运行tf.exe并获取某些二进制文件的最新版本.一切正常,但我想将下载文件的属性更改为可写(通过嘲笑这些文件是只读的).为此我想确定文件的本地路径并使用批处理中的attrib-command.
tf.exe workfold [工作区]向我展示了某种列表中的本地路径,但它会更容易,如果它只显示我想要的东西,那么我可以使用提示.到现在为止它看起来像这样:
tf.exe workfold [Workspace]
=======================================
Arbeitsbereich: XYZ-xxxxxx (Username)
Auflistung: TFS-URL
[Workspace]: C:\xxx\TFS\xxx
Run Code Online (Sandbox Code Playgroud)
是否可以仅确定TFS工作区的本地路径映射,以便我可以使用attrib-command的提示而无需解析?
下面这个(粗俗!!!)的概念怎么样?
function Get-TfsWorkfold([string]$TfsCollection, [string]$TfsWorkspace)
{
$TfExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 10.0\Common7\IDE\TF.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:\temp\test.txt
Select-String c:\temp\test.txt -pattern:': ' | Select-Object Line | Handle-Path
Run Code Online (Sandbox Code Playgroud)
Handle-Path 中的最后一行是示例,您可以用您想要的任何内容重新编写。它是 PowerShell,但它应该按您想要的方式工作。
替换 {serverAndcollection} 和 {workspace}。
| 归档时间: |
|
| 查看次数: |
3423 次 |
| 最近记录: |