{"id":26645,"date":"2016-12-12T12:18:00","date_gmt":"2016-12-12T20:18:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/?p=26645"},"modified":"2019-02-14T15:55:58","modified_gmt":"2019-02-14T23:55:58","slug":"how-to-recreate-the-tfvc-team-project-folder","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/how-to-recreate-the-tfvc-team-project-folder\/","title":{"rendered":"How to recreate the TFVC team project folder"},"content":{"rendered":"<p>We&#8217;ve had a handful of support calls lately from customers who deleted their team project folder in TFVC. tf.exe makes it easy to do, but not easy to undo. Fortunately, the fix is straightforward, and <a href=\"https:\/\/blogs.msdn.microsoft.com\/wlennon\/\">Will Lennon<\/a>\u00a0has <a href=\"https:\/\/blogs.msdn.microsoft.com\/wlennon\/2016\/12\/12\/recreating-the-tfvc-team-project-folder\/\">written it up in a blog post<\/a>.\u00a0With Will&#8217;s permission, I&#8217;m reblogging the contents below.<\/p>\n<hr \/>\n<p>TF.exe makes it easy to destroy a TFVC team project folder, but if you do it\u2019s not as easy to recreate it.<\/p>\n<p>You can destroy all TFVC data in a team project by running\u00a0 <strong>tf.exe destroy $\/&lt;projectName&gt;<\/strong><\/p>\n<p>Then\u00a0if you try to navigate TFVC in a web browser, you\u2019ll see an error like this:<\/p>\n<p><strong>TFS.WebApi.Exception: The items requested either do not exist on the server at the specified versions, or you do not have permission to access them.<\/strong><\/p>\n<p>If you decide you want to add back the team project folder, you cannot use tf.exe to do it.\u00a0 There is no cmdline equivalent to recreate that team project folder.\u00a0 If you try <strong>tf.exe add &lt;projectName&gt;<\/strong> you\u2019ll see an error like this:<\/p>\n<p><strong>TF10169: Unsupported pending change attempted on team project folder $\/projectName.\u00a0 Use the Project Creation Wizard in Team Explorer to create a project or the Team Project deletion tool to delete one.<\/strong><\/p>\n<p>That error message isn\u2019t helpful when you already have a team project with this name and only the TFVC\u00a0project folder is missing.<\/p>\n<p>To fix this, you\u2019ll need to use the TFS client OM.\u00a0 Here is a PowerShell script that will recreate the team project folder.\u00a0 You will need to run this on a machine that has Visual Studio installed. The running user must also have administrator permissions to your TFS collection.<\/p>\n<p>Note that this script will recreate the project folder, but it will not recreate the build and lab templates that are created when a project is created but were destroyed when they ran <strong>tf.exe destroy<\/strong>. If you want those templates, you can copy them from any existing project.<\/p>\n<p>You will need to update the <code>$accountName<\/code> and <code>$projectName<\/code> variables below. If you install Visual Studio in a non-default path, you\u2019ll also need to update the <code>$path<\/code> and <code>$path2<\/code> variables.\u00a0 <code>$accountName<\/code> could be a VSTS account URL or an on-premises TFS collection URL.<\/p>\n<pre><code>$accountName = \"<a href=\"https:\/\/%3Caccountname%3E.visualstudio.com\/\">https:\/\/&lt;accountName&gt;.visualstudio.com<\/a>\"\n$projectName = \"&lt;projectName&gt;\"\n$path = \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\"\n$path2 = \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\PrivateAssemblies\"\nAdd-Type -Path \"$path\\Microsoft.TeamFoundation.Client.dll\"\nAdd-Type -Path \"$path\\Microsoft.TeamFoundation.VersionControl.Client.dll\"\nAdd-Type -Path \"$path\\Microsoft.TeamFoundation.VersionControl.Common.dll\"\nAdd-Type -Path \"$path2\\Microsoft.IdentityModel.Clients.ActiveDirectory.dll\"\nAdd-Type -Path \"$path\\Microsoft.VisualStudio.Services.Client.dll\"\n$tpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($accountName)\n$vc = $tpc.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])\n$options = New-Object Microsoft.TeamFoundation.VersionControl.Client.TeamProjectFolderOptions($projectName)\n$vc.CreateTeamProjectFolder($options)<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve had a handful of support calls lately from customers who deleted their team project folder in TFVC. tf.exe makes it easy to do, but not easy to undo. Fortunately, the fix is straightforward, and Will Lennon\u00a0has written it up in a blog post.\u00a0With Will&#8217;s permission, I&#8217;m reblogging the contents below. TF.exe makes it easy [&hellip;]<\/p>\n","protected":false},"author":719,"featured_media":45953,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,225],"tags":[],"class_list":["post-26645","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-git"],"acf":[],"blog_post_summary":"<p>We&#8217;ve had a handful of support calls lately from customers who deleted their team project folder in TFVC. tf.exe makes it easy to do, but not easy to undo. Fortunately, the fix is straightforward, and Will Lennon\u00a0has written it up in a blog post.\u00a0With Will&#8217;s permission, I&#8217;m reblogging the contents below. TF.exe makes it easy [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/26645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/719"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=26645"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/26645\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=26645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=26645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=26645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}