简体   繁体   中英

Powershell: How to copy a file from TFS to a different destination

I'm writing a powershell script for deployment. I need to copy changed files from TFS to our Test Server. I have been able to retrieve the change sets, and I have been able to drill down to the Item. I have access to the path of the source file.

Does anyone know an efficiect way of doing this? Do I need to use the DownloadFile cmdlet or can I just use the Copy-Item cmdlet.

path of sourcefile is $file.ServerItem which resolves to, for example, $/Project/PromonetBaseline/Main/Source/ItemHierarchy.vb

Destination is a path like \\\\104Server\\WebApps\\PromonetBaseline\\Main\\Source\\ItemHierarchy.vb

Is there a neat way to do this programatically?

Any input is appreciated.

Thanks, Akin

For something like this, I would set up a local workfold mapping for the source files, get those files and then use Copy-Item to copy the source files to the destination folder. You can use the -Force parameter on Copy-Item to overwrite an existing file.

Another option is to use tf view itemspec /i > tempfilename to get the files from the server without creating a local workfold mapping.

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