TFS - Get latest version of multiple files - visual-studio-2013

Could someone help me: How to get latest version of multiple files in TFS?
I'm starting to try automating the publishing of a project that is often changing, start with this problem.
So let's say that I have a list of 10 changed files in TFS that is not in the same changeset, and I need some tool/add-in/script that can get latest version of all those 10 files in one click/enter.
Anyway to do that, or any suggestion for me to start searching? Thanks for any help!

You can call the tf.exe command like this:
tf get file1.cs
tf get file2.cs
...
And then do that for every file. If they are all in the same folder you can just specify the folder and all files will be refreshed. You can also specify their common ancestor and add the /recursive option:
tf get ancestorFolder /recursive
Here is the full reference for the tfs get command.

Assuming that you know which files you need, the below script can help.
tf get "tfs path to file/folder" /force /recurse
use /force when you need to overwrite existing file. use /recurse when you want to get all files within a folder.
you can run this inside dos for loop command. Something like:
FOR /F ["options"] %%variable IN (<file name containing list of files>) DO tf get "%%variable" /force /recurse
You would need to study ["options"] as it's difficult over here to explain everything.
Alternatively you can use same logic inside powershell but there you would need to load tfs assemblies and run the required commands but will give you more flexibility and control with what you want to do.
Get Latest Version of Folder from TFS, using Powershell
How to get latest version of specific project in TFS using Powershell.

Related

List the modified files in intellij or perforce through command line

I need to write a script the lists the modified files within an intellij project, this project uses perforce as VCS.
Is there an IDEA feature accessible from command line that can do this job?
Otherwise how can I list all the modified files within a project using the p4 command?
The command you need is p4 opened.
IntelliJ IDEA's version control integration features are not accessible through command line, and even if they were, it would still be much faster to query the version control system directly.

TFS build controller does not support xcopy [source] [destination] /e

I am facing an issue when trying to generate build. I have post deploy batch command where I am copying files and folder using xcopy.
This doesn't seem to work.
Is there any solution or work around for this.
On TFS and VSTS you should use the Copy Files task provided.
https://www.visualstudio.com/en-us/docs/build/steps/utility/copy-files
Just drop the task onto the execution stuck and configure it as per the documentation.
You will still not be able to access disc location outside of the agent permission scope.

How to implement a delete folders step in TeamCity

In TeamCity 8.1 I've just pulled down my source code and the first thing I want to do is delete a bunch of subfolders from what I've just retrieved.
I can't use exclusions in the 'Checkout Rules' so I guess I need a separate step to run immediately after retrieving source code.
I guess I need a CommandLine Step? If so I can't seem to find much information about using this to delete a number of sub folders?
Anyone with experience in this area?
You can do it in two ways
use a command line to delete the folders using windows/unix commands. Teamcity publishes a property called teamcity.build.checkoutDir using which you can go the directory and run the necessary delete commands(based on the OS where you are checking out).
A better way of doing this would be to add a target in your build.xml and call the target as the first step of your build
In our team city setup we wanted to delete all existing files in working directory.
We have first build step which cleans up working directory contents using custom command line script.
del /s /q .
for /d %%%y in (.\*) do #rd /s /q "%%%y"
Note: We don't have VCS attached in this build configuration. If you have VCS attached then this solution won't work because TC will first download/copy contents from VCS then this build step will delete all the contents downloaded from VCS.

Synchronizing Visual SVN with IIS for web development (or to any other folder)

How to get the latest version of the project file to another folder on every commit?
I'm using VisualSVN server and I think we can do this on post-commit in hooks, but I don't know how. Server is on Windows.
Actually I need to get the latest version of the file to \www folder of IIS7. Simply, get the latest file to another folder.
I've added following code in post-commit hook (for copying latest version files to D:\Destination).
svn export --force file:///D:/Repositories/myproject D:\Destination
exit 2
It works fine for me.
If your trying to export this to a directory of website, need to change the directory permission. Visual SVN is using NETWORK SERVICE.
If you use the same file in more than single folder inside your repository and you Subversion is 1.6 or newer, you can use file-type of svn:externals without binding to revision.
In this case committed to SOURCE file will be updated in Working Copy of TARGET after usual svn up
but I don't know how
You correctly say that you have to do it by post-commit, but if you mean you don't know the process, here is how.
Your post-commit hook is a script which is called after every commit to a project in your SVN repository. There is a file called post-commit in the hooks folder of every repository. Change the file to include the necessary commands* to do the copying for you and make it an executable post-commit.exe.
Afterwards, every time you commit a new revision, that script should handle it for you.
*By necessary commands I mean, either do the copying via the Windows cmd prompt, or call another script to do the job from within post-commit.exe.
Also, even though SVN docs mention that the post-commit hook needs to be either .bat or .exe file, I've had it working only when it's .exe on my machine.
You can convert .bat files into binary .exe using tools available here and here. The second one is much more user-friendly. I hope it helps.

How do I keep Resharper Files out of SVN?

I am using VS2008 and Resharper. Resharper creates a directory _Resharper.ProjectName. These files provide no value for source control that I am aware of and cause issues when committing changes. How can I get SVN to ignore them? I am using TortoiseSVN as my interface for SVN.
EDIT: You guys are fast.
Here's a link to show the ignoring process in TortoiseSVN
Add the file names (or even the pattern _Resharper.*) to the svn:ignore property for its parent directory.
Gonna post an answer to my own question here as I read the manual after I typed this up. In TortoiseSVN, goto settings. Add
*ReSharper*
to the "Global ignore pattern". Adding items to the global ignore pattern means that these files will be ignored for any project you work on for the client with TortoiseSVN installed, so it might not be appropriate to use the global ignore in all cases.
You can also add specific files and directories to the ignore list for individual projects if you select this from the TortoiseSVN menu BEFORE they have been added to your repository. The "BEFORE" part is what tripped me up originally. Since this is a single developer project, I've been checking in binaries, etc. b/c it has no consequence for other developers, and the Resharper files got in there.
Store Resharper caches in system temp folder.
Check First setting page in r#.
Environment -> General -> System -> Store caches ..
Short answer: the "svn:ignore" property
Long answer:
# cd /your/working/copy
# export EDITOR=vi
# svn propedit svn:ignore .
(add "_Resharper.ProjectName" on its own line and write the file out)
Edit: erg... doh, just realized you said tortoise... this is how you do it with the command-line version of SVN
svn has an "ignore" property you can attach to a filename pattern or a directory. Files and directories that are ignored won't be reported in "svn st" commands and won't go into the repo.
Example: you have C source code in .c and .h files, but the compiler creates a bunch of .o files that you don't want subversion to bother telling you about. You can use Subversion's properties feature to tell it to ignore these.
For a few files in one checked-out working directory, for example myproject/mysource/
bash> svn propedit svn:ignore mysource
In the text editor that pops up (in linux, probably vi or whatever your EDITOR env var is set to), add one filename pattern per line. Do not put a trailing space after the pattern (this confuses svn).
*.o
*.bak
That's all. You may want to do a commit right away, since sometimes svn gets fussy about users making too many different kinds of changes to files between commits. (my rule is: if in doubt, commit. It's cheap)
For a type of file appearing in many places in a sprawling directory tree, edit the subversion config file kept inside the repository. This requires the repository administrator's action, unless you have direct access to the repository (not through svn: or http: or file:, but can 'cd' to the repository location and 'ls' its files). The svn books should have the details; i don't recall offhand right now.
Since i don't use Tortoise, i don't know how directly the description above translates - but that's why we have editable answers (joy!)
This blog post provides a example on how to do what you want on via command line svn.
http://sdesmedt.wordpress.com/2006/12/10/how-to-make-subversion-ignore-files-and-folders/
These change will be reflected in TortoiseSVN.
I believe there is a way to do it via tortoise however i don't have a windows vm accessible atm, sorry :(
SVN only controls what you put into it when creating your repository. Don't just import your entire project folder but import a "clean" folder BEFORE doing a build. After the build you get all the object files or your _Resharper folder etc. but they are not version controlled.
I forgot: the svn:ignore command is another possibility to tell SVN to exclude certain files. You can add this as a property to the version controlled folders, e.g. with TortoiseSVN.

Resources