简体   繁体   中英

Is it possible to create a new TFS workspace in PowerShell with Power Tools?

I am building a function in PowerShell that creates a new Workspace and gets the latest version of the directory specified in addition to some other TFS and file system related tasks. Right now I'm using a mixture of PowerTools and TFS assemblies to get the job done. It appears I can do just about everything with Power Tools, except creating a new workspace. I haven't figured out how to do this without explicitly loading the Team Foundation assemblies. Is it even possible and if so how?

Here's what I'm doing right now

#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)

The only new commands in the TFPT snapin is New-TfsChangeset and New-TfsShelveset . Is there a reason you can't use tf.exe workspace /new ... and tf.exe workfold ... ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM