0

I want to use the latest contents of a XAML file stored in TFS Source Control and embed it in a string variable, which is to be submitted as a query to MS SQL Server.

I have been using TFS Power Tools cmdlets in PowerShell (such as Get-TfsChildItem and Select-TfsItem) to successfully get handles on TFS files, changesets and shelvesets. But I cannot identify any methods or properties on these objects that would allow me to directly get the contents of a file into a variable.

I want to do something like this:

$tfsFileName = "$/MyBranch/MyFile.xaml"
$tfsServerName = "http://myTFSServer:8080/tfs"
$tfsServer = Get-TfsServer $tfsServerName

$xamlFile = Get-TfsChildItem -Item $tfsFileName -Server $tfsServer

$xamlContent = (Get-Content $xamlFile)

Is this possible, or do I always have to perform a Get Latest using tf.exe, and then get the contents of the local file?

peterk411
  • 236
  • 1
  • 10

2 Answers2

0

I think you want the DownloadFile method on an Item. Eg:

$xamlFile = Get-TfsChildItem -Item $tfsFileName -Server $tfsServer
$xamlFile.DownloadFile("C:\Temp\file.xaml")
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • 1
    I tried calling that method and got this error message:Exception calling "DownloadFile" with "1" argument(s): "Team Foundation services are not available from server http://myTFSServer:8080/tfs. Technical information (for administrator): Cannot access a disposed object. Object name: 'Microsoft.TeamFoundation.Client.TfsTeamProjectCollection'." – peterk411 Nov 21 '12 at 22:03
0

When I got the message about Team Foundation Services not being available on my server it turns out I had the wrong URI. I originally had http://tfs.mycompanyweb.mycompany.com:8080/tfs/ist/ISTDatabaseTools but changed it to http://tfs.mycompanyweb.mycompany.com:8080/tfs/ist and that error cleared up.

I still fail to get DownloadFile to work properly though. I'm trying to do something similar myself.

Joe