<p>How do I get the latest version of my solution recursively like its done in the solution explorer context menu of Visual Studio? I want to do this from the command line or via a macro. I'm trying to automate a part of my daily routine by using a set of batch files. I am sure a lot of developers would love to have something like this.</p>

<p><code>tf get</code> only gets contents of a folder recursively (not solution). It does not look at project dependencies and so on. That won't work.</p>

[{'answer_id': 35169, 'author': 'NotMe', 'author_id': 2424, 'author_profile': 'https://Stackoverflow.com/users/2424', 'pm_score': 1, 'selected': False, 'text': "<p>Well... It looks like you have three options.</p>\n\n<ol>\n<li><p>In your batch file, issue a tf get at each directory branch you want.</p></li>\n<li><p>reorganize your solution so that all of the dependencies are under the same root path.</p></li>\n<li><p>Use the visual way of right clicking on the loaded project and issuing the get command.</p></li>\n</ol>\n\n<p>The only time it's actually solution aware is when the project is loaded in the IDE; or when it's loaded by the build servers.</p>\n"}, {'answer_id': 52525, 'author': 'NotMe', 'author_id': 2424, 'author_profile': 'https://Stackoverflow.com/users/2424', 'pm_score': 0, 'selected': False, 'text': '<p>I know you mentioned batch files, but let me throw something else out for you.</p>\n\n<p>I\'m going to guess that you are using the 2005 version of TFS.  2008 has all of the scheduling stuff built in.  </p>\n\n<p>However, you could also use <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" rel="nofollow noreferrer">CruiseControl.net</a> to do scheduled builds for you.  I\'ve used both TFS 2008 and CruiseControl and they both seem to work just fine.</p>\n'}, {'answer_id': 185256, 'author': 'tbreffni', 'author_id': 637, 'author_profile': 'https://Stackoverflow.com/users/637', 'pm_score': 3, 'selected': True, 'text': '<p>TFS has a <a href="http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx" rel="nofollow noreferrer">.Net SDK</a> that allows you to create your own custom programs that interact with a TFS Server.  You could write a small program that performs the task you need:</p>\n\n<pre><code>TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("MyServer");\nVersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));\n\nWorkSpace[] myWorkSpaces = vcs.QueryWorkSpaces("MyWorkSpaceName", "MyLoginName", "MyComputer");\n\nmyWorkSpaces[0].Get(VersionSpec.Latest, GetOptions.GetAll);\n</code></pre>\n'}, {'answer_id': 1560520, 'author': 'NotMe', 'author_id': 2424, 'author_profile': 'https://Stackoverflow.com/users/2424', 'pm_score': 0, 'selected': False, 'text': '<p>One more possible solution is to use powershell.  The following link is to a code project sample which shows how to get a solution from TFS and build it locally.  Powershell is a much better solution than regular batch files.</p>\n\n<p><a href="http://www.codeproject.com/KB/install/ExtractAndBuild.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/install/ExtractAndBuild.aspx</a></p>\n'}, {'answer_id': 1564465, 'author': 'Richard Berg', 'author_id': 74439, 'author_profile': 'https://Stackoverflow.com/users/74439', 'pm_score': 0, 'selected': False, 'text': '<p>Don\'t do this.  VS is not nearly as smart as you think.  (As evidenced by the mysterious &amp; futile checkouts that everyone has experienced for 3+ product cycles, you &amp; I included.  This is not the mark of a reliable system!)  </p>\n\n<p>What you describe only works for project-to-project references.  Running source control operations from Solution Explorer will "by design" omit:</p>\n\n<ul>\n<li>project-to-assembly references</li>\n<li>video, sound, PDFs, any other type of media that VS doesn\'t support but may play an integral role in the product</li>\n<li>MSBuild *.targets files that are referenced in your projects</li>\n<li>any files of any kind that are referenced from custom targets</li>\n<li>any 3rd party executables required by the build process</li>\n<li>etc</li>\n</ul>\n\n<p>Just say <strong>no</strong> to incomplete synchronization.  Down that path, only headaches lie.  </p>\n\n<p>Run \'tf get\' with no path scope from the command line, or rightclick -> Get from the root $/ node in Source Control Explorer.</p>\n'}, {'answer_id': 3320993, 'author': 'Mike Diehl', 'author_id': 400539, 'author_profile': 'https://Stackoverflow.com/users/400539', 'pm_score': 2, 'selected': False, 'text': '<p>I agree that Solution Explorer will "by design" omit all those objects, but only if you do not include them as Solution items, which I believe you <em>should</em> include in your solutions, so that a newbie can open the solution, do a Get Latest, and know they have all the dependencies needed for that solution, and not have to learn how to do it via a command line tool, or use Source Control Explorer if they don\'t want to. </p>\n\n<p>Including all the non-code dependencies as solution items (we organize the solution folders using the same folder structure as their source control folders) reduces "voodoo" knowledge required to open and compile the solution for new developers on a project. </p>\n\n<p>It would be good if you could link entire folder trees to a solution folder in the VS solution.</p>\n'}, {'answer_id': 10179887, 'author': 'TheKnucklehead', 'author_id': 1276038, 'author_profile': 'https://Stackoverflow.com/users/1276038', 'pm_score': 2, 'selected': False, 'text': '<p>If you have dependent projects under a different folder. Use this to loop through all of the sub directories to grab the latest for each project:</p>\n\n<p>Start in the main directory <code>C:\\Project\\SupportingProjects</code></p>\n\n<pre><code>FOR /D %%G IN ("*") DO ECHO ..from....%%G &amp;&amp; tf get C:\\Projects\\SupportingProjects\\%%G \n\n::Get the latest for the Main project\ntf get C:\\Projects\\MainProject /recursive \n</code></pre>\n\n<p>In my case the MainProject folder contains the solution file and the project file.</p>\n\n<p>I found this easy and simple. </p>\n\n<p>More on the FOR command: <a href="http://ss64.com/nt/for_d.html" rel="nofollow">http://ss64.com/nt/for_d.html</a></p>\n'}]
['https://Stackoverflow.com/questions/34204', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/45603/']