How to cloak directories in TFS command line - command-line

I want to ignore some directory while checking out code from TFS using TFS command line.
For example, say i have a TFS url path where i have two directory, namely Iteration9 and Iteration11 .
Now I want to check out from that url path such a way so that only Iteration9 gets checked out and ignore the Iteration11
So far i am following the steps,
Create a workspace named cloak_1:
./tf workspace -new -collection:http://tfsna.int.com:8080/tfs/C_Collection -login:user27#domain,password cloak_1;
Cloak the Iteration11 directory which i don't want:
./tf workfold -cloak $/Cobalt Search/Releases/1.0/Iteration11 -workspace:cloak_1 -login:user27#domain,'password';
Map the path to my local Directory:
./tf workfold -map -workspace:cloak_1 -login:user27#domain,password '$/C_Search/Releases/1.0' /tfs/TEE-CLC-10.1.0/cl-test1;
Finally get the source code:
./tf get -recursive -login:user27#domain,password /tfs/TEE-CLC-10.1.0/cl-test1;
But the cloak is not working here. i am getting both the directory in my local folder. please tell me where i am doing wrong.

You can create the workspace configuration that your want in visual studio with the UI and then clone it when you want to use it.
http://roadtoalm.com/2011/10/25/hidden-gems-in-tfspart-6-managing-workspaces-in-tfs-with-workspace-templates/

Related

How do I fix my source control tab on VS Code?

Every time I open a new folder from my files, Source Control thinks it's a repository. For example:
https://i.stack.imgur.com/fs4Ir.png
These are all files I've created in VS Code, but it considers them "untracked"
If VS Code shows the source control tab, it's because it found a .git folder either in the folder you opened or any of the ancestor. It will looks for such folder recursively, up to the root.
This folder contains all the local git database stuff.
You should look inside your folder structure up to find such folder and remove it (it's probably an hidden folder, you should set your options accordingly).
Another way to find where's this folder is located is to open a command prompt, cd your folder and run git rev-parse --show-toplevel. This will output the repo root folder.

Nuget restore command from different directory

I try to run the following nuget command ,
in the "D:\work\Development\" directory there is solution file
nuget.exe restore D:\work\Development\
I received an error
Could not find a part of the path C:\work\Development
When I copy the nuget.exe file to the directory D:\work\Development and run resotre like so
nuget.exe restore
from there it works
How can I make restore work from another directory than the one my solution is in?
What I ended up doing is using restore from with a relative path like so :
nuget.exe restore ..\
You should pass in the path to the .sln file, such as D:\work\Development\mysolution.sln or path to the packages.config file.
Please refer to this doc for how to use the nuget.exe restore command.
http://docs.nuget.org/docs/reference/command-line-reference#Restore_command
I had a similar issue getting a relative path to work, but in my case I was accessing the nuget.exe in a subfolder as well as trying to restore packages in another folder.
I realised that the restore command path is based on the directory you are running the command from, not the directory the nuget.exe file is in.
eg. If your nuget.exe file is in a Projects\.nuget subfolder, and you are in the root directory (one up from Projects), running this will restore any packages for a solution that is in the Projects subfolder.
Projects\.nuget\nuget.exe restore Projects

TFS Creating Build script for releases

I want to be able to set up a semi automatic Build script to check out a specific commit from our TFS server to a non generic folder to then cause the code to be built and packaged to enable a release.
I understand how to use the command line, and can script it fine, but its how to create a temporary workspace that will not interfere with the existing workspace on the machine to check the code out into.
I will have to research how to build the solution as well from the commandline but that may not be as hard as this...
You can use the command line tool tf.exe to create a new workspace e.g.:
tf workspace /new workspace_name`;username /collection:http://myserver:8080/tfs/DefaultCollection
You can get work folder mappings by using a template when creating the new workspace. See the /template parameter on tf workspace. Or you can use the tf workfold /map command to create work folder mappings for the new workspace. When you're done, use tf workspace /delete to delete the workspace.

How to export the files under a label from TFS in a script using tf?

I need a batch script that uses tf to retrieve the directory structure for a label in TFS, something like the equivalent of svn export, while not messing up with my current working workspace.
This is what I managed to come up with:
tf workspace /new TemporaryWorkspace /noprompt
This will create a new workspace, but with the following working folder:
$/: C:\
(considering that I ran the command from C:)
This is not what I want, but "tf workspace /new" doesn't seem to allow specifying the mapping, so I ran this to remove the default mapping:
tf workfold /unmap $/ /workspace:TemporaryWorkspace
then this one to create my desired mapping.
tf workfold /workspace:TemporaryWorkspace /map $/Project/Path C:\Temp\Path
Change the current directory to the local working folder (I don't know of another way to select the current workspace)
PUSHD C:\Temp\Path
Now I can finally retrieve the label and do my stuff with it.
tf get /version:LMyBeautifulLabel
Now the clean up.
tf workspace /delete TemporaryWorkspace /noprompt
Go back
POPD
All these seems a bit too cumbersome for my humble purpose. Is there a simpler way?
Thanks.
Unfortunately, you will need to create a workspace with the proper working folder mappings and then run the get. There's no one-liner alias to set this up for you.
You may be able to get by with creating a longer-lived workspace with the proper working folder mappings that you need not delete, but certainly if you're using this workflow frequently but with different labels or in different locations, creating a new temporary workspace each time probably does make the most sense.
Your best solution here is to either create a command script that executes this workflow or use the little known script functionality of the tf command line client. You can run a tf script by using:
tf #<filename>
or simply using:
tf #
to read from standard input.

Check in a file to TFS (command line) withouth a work space

Is it possible to just say to TFS that I have a file (call it Version.txt) and I want it to be checked in at a location (say $/MyProject/MyVersionLocation) and not have any workspace setup for that location?
Something like (pretend Syntax):
tf.exe c:\Version.txt CheckIn $/MyProject/MyVersionLocation /WorkSpaceOverride
If so, how do you do it?
It is not possible to checkin a file without a workspace mapping for that path.
One option would be to use a combination of "tf workspace" and "tf workfold" to dynamically create a workspace before checking in.
For example:
tf workspace /collection:http://server:8080/tfs/Collection /new TempWorkspace /noprompt
tf workfold /collection:<server> /workspace:TempWorkspace /map $/MyProject/MyVersionLocation/Version.txt C:\Version.txt