locked
TFS proxy cache refresh using TFS API RRS feed

  • Question

  • Hi all,

    I have a requirement where I want to refresh the proxy server cache for team project using TFS API. How can I do this ?

    Look for API functionality that will enable a proxy refresh for a given Team Project.

    Please help me.

    Thanks,

    Friday, January 15, 2016 6:15 AM

Answers

  • Thanks for your reply. I am going to submit the feature request.

    As I could not find the TFS API to refresh the Team Foundation Server Proxy Cache. I used alternate way to do this using TFS API and PowerShell Script.

    The alternate approach I have followed is:-

    1. Create a workspace using PowerShell

    2. Map the local folder path with TFS server path ( Mapping) using powershell

    3. Perform get-lateset on this workspace using PowerShell

    4. Delete the Workspace using PowerShell script.

    The working PowerShell Script is :-

                    

    param (
          [string]$tfsServer = "https://nathcorpdev.nc.com/tfs",
            [string]$tfsLocation = "$/ncsync/psscripts/PowerShell",
            [string]$localFolder ="c:\LocalFolderPath"

        )
       $clientDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
       $versionControlClientDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
       $versionControlCommonDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Common.dll"

       #Load the Assemblies
      [Reflection.Assembly]::LoadFrom($clientDll)
       [Reflection.Assembly]::LoadFrom($versionControlClientDll)
      [Reflection.Assembly]::LoadFrom($versionControlCommonDll)

      #Set up connection to TFS Server and get version control
       $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer)
       $versionControlType = [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]
      $versionControlServer = $tfs.GetService($versionControlType)

       #Create a "workspace" and map a local folder to a TFS location
       $workspace = $versionControlServer.CreateWorkspace("PowerShellWorkspace",$versionControlServer.AuthenticatedUser)
       echo "Created Workspace "  $workspace.Name
      $workingfolder = New-Object Microsoft.TeamFoundation.VersionControl.Client.WorkingFolder($tfsLocation,$localFolder)
       $workspace.CreateMapping($workingFolder)


    # perform get-latest on the new workspace

    echo "Getting Latest Code"
    $workspace.Get()
    echo "GET DONE... Script Done Ready for Use"

    # delete the new workspace.

     $workspace.Delete()

    Above Powershell script is performing all the steps given above (steps 1 to 4 ).

    I am sharing it here, so that other community members can give their feedback and suggestion.

    Thanks, Let me know if above script is ok.

    Monday, January 18, 2016 7:28 AM

All replies

  • Hi Vishwajeet,

    As far as I know, there isn’t the API of TFS that used to refresh the proxy cache.

    I suggest that you could submit the feature request here: http://visualstudio.uservoice.com/forums/330519-team-services/category/145284-version-control-git-tfvc, if you submit this suggestion, you might post that link here which will benefit others who has the similar issue.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 18, 2016 6:25 AM
    Moderator
  • Thanks for your reply. I am going to submit the feature request.

    As I could not find the TFS API to refresh the Team Foundation Server Proxy Cache. I used alternate way to do this using TFS API and PowerShell Script.

    The alternate approach I have followed is:-

    1. Create a workspace using PowerShell

    2. Map the local folder path with TFS server path ( Mapping) using powershell

    3. Perform get-lateset on this workspace using PowerShell

    4. Delete the Workspace using PowerShell script.

    The working PowerShell Script is :-

                    

    param (
          [string]$tfsServer = "https://nathcorpdev.nc.com/tfs",
            [string]$tfsLocation = "$/ncsync/psscripts/PowerShell",
            [string]$localFolder ="c:\LocalFolderPath"

        )
       $clientDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
       $versionControlClientDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
       $versionControlCommonDll = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Common.dll"

       #Load the Assemblies
      [Reflection.Assembly]::LoadFrom($clientDll)
       [Reflection.Assembly]::LoadFrom($versionControlClientDll)
      [Reflection.Assembly]::LoadFrom($versionControlCommonDll)

      #Set up connection to TFS Server and get version control
       $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer)
       $versionControlType = [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]
      $versionControlServer = $tfs.GetService($versionControlType)

       #Create a "workspace" and map a local folder to a TFS location
       $workspace = $versionControlServer.CreateWorkspace("PowerShellWorkspace",$versionControlServer.AuthenticatedUser)
       echo "Created Workspace "  $workspace.Name
      $workingfolder = New-Object Microsoft.TeamFoundation.VersionControl.Client.WorkingFolder($tfsLocation,$localFolder)
       $workspace.CreateMapping($workingFolder)


    # perform get-latest on the new workspace

    echo "Getting Latest Code"
    $workspace.Get()
    echo "GET DONE... Script Done Ready for Use"

    # delete the new workspace.

     $workspace.Delete()

    Above Powershell script is performing all the steps given above (steps 1 to 4 ).

    I am sharing it here, so that other community members can give their feedback and suggestion.

    Thanks, Let me know if above script is ok.

    Monday, January 18, 2016 7:28 AM
  • Hi Vishwajeet,

    Thanks for sharing the workaround. I think the script is ok in proxy server.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 19, 2016 2:47 AM
    Moderator