0
我在PowerShell中构建一个函数,该函数创建一个新的Workspace并获取除了一些其他TFS和文件系统相关任务以外指定的最新版本的目录。现在我正在使用PowerTools和TFS组合件的混合物来完成工作。除了创建一个新的工作区之外,我似乎可以用Power Tools来做所有的事情。我还没有想出如何在没有显式加载Team Foundation程序集的情况下执行此操作。这是甚至可能的,如果是的话如何?是否可以使用Power Tools在PowerShell中创建新的TFS工作区?
下面是我在TFPT管理单元做什么,现在
#Install required TFS assemblies
"Microsoft.TeamFoundation.Client",
"Microsoft.TeamFoundation.VersionControl.Common",
"Microsoft.TeamFoundation.VersionControl.Client" |
ForEach-Object { Add-Type -AssemblyName "$_, Version=11.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a" }
#Install TFS PowerTools snappin for basic tasks
If ((Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
}
## Set applicable parameters
#Get the TFS server object
$tfs=Get-TfsServer -Name $tfsName
#Get the version control service object
#This is what I want to do with PowerTools - like a new-item or something
$vcs = $tfs.GetService([type]"Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer")
#Create a Workspace parameters object
$workspaceParameters = New-Object Microsoft.TeamFoundation.VersionControl.Client.CreateWorkspaceParameters -ArgumentList $wsName
#Create the Workspace
$tfsw = $vcs.CreateWorkspace($workspaceParameters)
# Add any working folders that you would defined below
$tfsw.Map($tfsLocation, $localFolder)
没有理由。我是PoSh和管理TFS的新手。我正在使用的解决方案只是我自己有限的知识能够找到的变体。我被引导到了PowerTools,但又是另一位用户,但到目前为止,我对有关cmdlet的可用功能感到有点不知所措。是否有tf.exe方法的任何先决条件?我需要担心的问题? –
同意TFPT。这是一个好的开始,但它可以做得更多。我真的很想念没有Get-TfsPermission cmdlet。我们在构建和测试脚本中使用了tf.exe。主要的pre-req是安装Visual Studio(或VS团队资源管理器),因为这是安装tf.exe。除此之外,您需要知道为了测试控制台exe是否成功,您应该在调用exe后检查$ LASTEXITCODE。另外,请注意使用分号的参数。这是一个声明分隔符PowerShell。 –
例如,该命令可能会导致PowerShell的tf状态出现问题。/r/workspace:*; johndoe'。你需要像这样指定它的状态。/r/workspace:*; johndoe'。或者,如果您使用的是V3或更高版本,请使用停止解析操作符,例如地位。/r - %/ workspace:*; johndoe'。请注意,使用 - %,它将PowerShell放入CMD中,如解析模式直到行结束。 –