0

I am writing automation script for creating local workspace and modify few files in local workspace and finally push the changes to the TFS server and Build the changes using Shelveset build and then checkin the changes if build succeeded.

Is there any way we can push the changes and shelve those changes in C#. I am trying to use tf commands but its not working as expected.

Do we have any command similar to got push in TFS?

Thanks in advance

Manju
  • 21
  • 2
  • 9
  • 1
    Why are the `tf` commands not working as-expected? What happens when you use them? – Dai Jun 11 '20 at 00:51
  • I am trying to execute below code but getting error "Path is not supported" while trying to download TFS code into local workspace. ProcessHelper.Run( LocalWorkspace, @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe", $"get \"https://xxxxx/tfs/yyyy/_versionControl?path=%24%2Fyyyy%2FMTE%2FProducts%2Fkkkk%2Fzzzzz\" \"{LocalWorkspace}\""); Definition: ProcessHelper.Run(string workingDirectory, string executable, string arguments) – Manju Jun 11 '20 at 13:06

1 Answers1

0

Is there any way we can push the changes and shelve those changes in C#. I am trying to use tf commands but its not working as expected.

According to the error message, it seems the path in your command line is not correct.

To download TFS code into local workspace, we need to have a local TFVC Workspace on your machine. If you don't have one (as it was my case), you need to create it. The following steps are partially extracted from https://stackoverflow.com/a/21785438/2816119:

  1. Create a local folder where you are going to download and locally store the source code.
  2. Open a command prompt window.
  3. Create a local workspace from your command prompt window with the following command:

    tf workspace -new MyWorkspace -collection:<<<http://full.URL.of/your/repository>>>
    
  4. Map your repository folder to your local folder with the following command:

    tf workfold -map '$/your/repository/folder/path' /your/local/folder/path -collection:<<<http://full.URL.of/your/repository>>> -workspace:MyWorkspace
    
  5. If everything went well, you'll see a new sub-folder ".tf" in your local folder.

Or you could use the command line "%PathToIde%\TF.exe" get $/Arquitectura/Main /recursive to download the TFS code into local workspace, you still ned create a workspace first.

Please check this document and this thread for some details.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks for the detailed explanation. I am able to download the TFS code into my local workspace and modify the changes. I used shelve command to shelve the pending changes but I am struggling to find the status of the shelve in order to kick off the build with Shelveset name. which means, I want to kick off shelveset build only if there are any pending changes else it should throw me some message like " there are no pending changes" and break. Please help if you have any idea on achieving this – Manju Jun 13 '20 at 02:58