2

I am following the recommended guidance for Team Foundation Server by mapping the root of the source control tree to a local folder. However, I do not want to map every folder underneath that root. I can cloak one folder at a time, but would prefer to cloak a number of folders at once. Is there a way to do so easily?

Robert Bernstein
  • 783
  • 12
  • 18

3 Answers3

8

I found another way to do this in PowerShell. Change to the mapped directory where you wish to cloak files and enter the following command:

Get-ChildItem | where {$_.PsIsContainer} | ForEach-Object { Write-Host $_.Name ; tf workfold /cloak $_.Name }

This will cloak every directory at the current folder level. If you wish to exclude certain directories from being cloaked at this level, add the -Exclude parameter:

Get-ChildItem -Exclude <foldernames> | where {$_.PsIsContainer} | ForEach-Object { Write-Host $_.Name ; tf workfold /cloak $_.Name }

where <foldernames> can be one or more folders separated by commas. Preferably each folder name can be embedded in double quotes (to allow spaces, for example).

Also if the tf command does not work, you can use the Set-Alias prior to this as explained in this answer: powershell tf command not recognized as the name of a cmlet

Community
  • 1
  • 1
Robert Bernstein
  • 783
  • 12
  • 18
  • You might want to add ' ; tf vc get $_.Name ' without quotes right before the last } to perform a get latest so that the cloaked folders are deleted from your hard drive and thereby making them appear cloaked also in the Source Control Explorer in Visual Studio. – MBWise Feb 14 '18 at 09:35
  • 1
    @MBWise In my experience performing the get from the command line is less reliable than doing it from Source Control Explorer. (I get errors at the command line but not in the IDE.) I understand these should be equivalent but at least for me they're apparently not. YMMV. – David Feb 14 '22 at 18:18
7

In the Edit Workspaces dialog box, in the Working folders list i suggest to change the setting from Active to Cloaked for each folder.

link : http://msdn.microsoft.com/en-us/library/ms181378(v=vs.110).aspx

based on this link : http://msdn.microsoft.com/en-us/library/ms181378%28VS.80%29.aspx

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
0

I know this is an older post, but for anyone who stumbles on it now (as I did) or in the future ...

You might also consider the approach described in this answer. Faster than cloaking in my experience.

Briefly, you use the Get Specific Version function; specifically, you fetch version 1 for any folders you do not want locally. (Version 1 contains only the repository root $/, so fetching that version of any folder will remove the local copy. See linked answer for details.)

David
  • 2,226
  • 32
  • 39