Visual Studio 2015 How to restore packages? - tfs

So my team mate commited some code in TFS and he added some new references. However these would not want to download even if the checkbox is checked insite the nuget package settings. So I tried deleting all the references from the solution explorer. How can I get them back as well as whatever my team mate commited to TFS?

right click on solution>source control>get specific version to undo changes.
If that doesn't bring your deleted files, you need to go to:
Tools->Options->Source Control->Visual Studio Team Foundation, then check
"Show deleted items in the Source Control Explorer"
checkbox.
Go to source control where your deleted files where located right click>source control>get specific version

Related

TFS not tracking changes if items added manually and not included into vs2015 solution

I've added a folder with asp.net core project which isn't supported by Visual Studio 2015 (which is used for everything else) and thus not included to the general solution.
To have those files in source control I had to manually add them using "add items to folder" command in source explorer. So they are checked-in but tfs not tracking changes for them anymore although there are differences that are shown if compare to the latest folder on the server:
How do I make TFS track them and show pending changes for edited files?
According to your description, looks like these files are all out side of Visual Studio.
Not sure if you are using server workspace or local workspace.
When adding or editing the workspace you click Advanced >> . There is a setting of Location: Local/Server.
For local workspace, when your script or anything else changes files outside Visual Studio, your workspace detects the changes automatically.
It also detects adds or deletes but you have to include them to your Pending Changes manually with the link under Excluded Changes.
For server workspace, you could choose to use Reconcile command. See https://stackoverflow.com/a/22860674/932282 for a complete answer.
Besides, you could also take a look at other solutions in below similar question:
How to have TFS 2010 detect changes done to files outside of Visual Studio?
Force TFS to detect changes
I think you just added them to source explorer and not to the solution, as you said. In this case, there is no editor application (even your VS) that is responsible for doing the check-out operation because they are not aware of TFS. On the other side, TFS can detect that changes have happened to the files but can not track them.
If you do not activate the "Get the latest version before check-out" option in your team project, then you can go to the source control and check-out those files manually and then check-in them manually again when your work with them is done.
Please before doing this, take a backup of your source code for caution.

Accidentally deleted branch from TFS - Undelete and Rollback not available?

I'm using Visual Studio 2015 and have deleted a branch from our TFS source control. Looking at other guides there's mention of being able to recover the branch by opening Source Control Explorer, right-click and select 'Undelete' or 'Rollback'. These options are not available
I have not got this branch mapped on any workspace. Clicking on 'Undo Pending Changes...' brings up a message saying there are no pending changes. How can I restore a branch on TFS? Is there a way I can enable Undelete or Rollback?
First, please make sure you or your teammates haven't destroyed this branch (After doing this, there is no way to recover it in TFS server).
If you delete this branch in Visual Studio,
To restore an item deleted from the server
From the menu bar choose Tools, Options.
On the Options dialog box, navigate to Source Control, Visual
Studio Team Foundation Server.
Select Show deleted items in the Source Control Explorer, and then
choose OK.
From the menu bar choose View, Other Windows, Source Control
Explorer.
In Source Control Explorer, navigate to the folder that contains the
item you want to restore.
Open the item’s context menu (select the item and right-click it) and
then choose Undelete.
If you delete this branch from your dev machine outside of Visual Studio,
Please check the solution from MSDN link Delete or restore files and folders
Morever, you can also try to use the undelete command restores items that were previously deleted. For Example:
tf undelete [/noget] [/lock:(none|checkin|checkout)]
[/recursive] itemspec[;deletionID] [/login:username,[password]]
Update:
Note: To be able to undelete a branch you must first map the parent folder/branch to your workspace. Now, the undelete option will be enable.
According to the screenshot, there is no workspace configured for it. Try configuring a work space for the project that include the deleted branch to see if the "Undelete" option will be activated.
In Visual Studio go to [Tools->Options] then Select [Source Control->visual Studio Team Founation Server] and check the [Show deleted items in the Source Control explorer].
After that, you can then right click a folder and say "Undelete"

Complete nuke all changes in visual studio and reset from TFS

I am using Visual Studio 2013. Regarding TFS workflow, there are issues I have when working on a bug or work item, after I am finished, I move the changes into a shelfset for further review, undo my changes by right clicking on the pending changes and clicking undo. The move on to the next issue or enhancement. The shelfsets can be indpendendly reviewed and then applied to whatever branch they are currently needed.
The problem I have is that undoing through visual studio does not completely reset the solution to a completely clean state. There are often orphaned files around or projects that have references to non-existing files or other such problems. I'd like to be able to completely nuke and reset my solutions from source control as if I am a new developer and I have not found an easy solution to do this.
Currently, the only way I can accomplish this is to go to "Source Control Explorer" remove the file system mapping for the project. Go to the file system, removed the folder. Go back into "Source Control Explorer" add the mappings back in. And then "Get Latest Version".
Is there an easy way to completely reset a solution in Visual Studio with TFS?
You can achieve this in Visual Studio 2010 without Power Tools. Process is likely similar for other VS versions.
Open the Source Control Explorer. Right-click the entry you want to reset, then choose "Get Specific Version." Select the version you want to reset to. Ensure that the two checkboxes are checked:
☑ Overwrite writeable files that are not checked out
☑ Overwrite all files even if the local version matches the specified version
This will overwrite all locally mapped files with the server's version. (And will correspondingly take time proportionate to the number of files.) I do not believe that this operation will remove any unmapped files.
If you have the Power Tools installed, call tfpt scorch /deletes /recursive /diff. That should make your local folder match the server exactly.
You can also call tfpt treeclean, which will just delete any item that is not mapped to TFS. It won't update or replace any changed files though, like scorch will.

TFS: Restore deleted folders and items

I deleted some files and some folders in TFS. Many check in's later I found out that I need the deleted functionality back in my project.
How can I restore the deleted files and folders?
In Team Explorer (in Visual Studio): Tools | Options | Source Control | Visual Studio Team Foundation Server and select Show Deleted Items...
Then in source control explorer you'll see the items greyed out. You can right click on them and Undelete. (This option will only be available if they, after the undelete, will be included in your current workspace).
NB. in newer versions of Visual Studio (eg. 2013) there is now a button to switch on display of deleted items in the Source Control Explorer's toolbar. Its the second button (here with the VS dark theme):
Alternatively using the TFS PowerToys you can look at history and right click to select "Rollback Entire Changeset": this will create pending changes to revert the changes of the selected changeset.
Edit: Added paragraph on newer versions of VS.
Assuming you successfully undelete as per #Richard's answer, there might still be an issue with the item appearing in Solution Explorer (at least it was for me using Visual Studio 2015). That is to say, the file is restored on your hard drive, in the proper place in your project's folder structure--but it's not showing in VS.
To resolve this, click the Show All Files button in Solution Explorer:
You will see your file, in a ghostly white icon. Right-click on it and select "Include in project". Save and check-in changes. You are back in business.
Recently I faced this issue, accidentally I deleted some classes which weren't checked in, I searched the name of the classes in my project directory (I was working on D365 project there is a bin folder in C:\AOSService\PackagesLocalDirectory\bin\XppSource) and saw that in the bin folder they were existed so I created new classes with the same name and copy the logic.
Also I should mention that no file was in recycle bin.

Getting "Failed to create mapping" when adding a solution to TFS source control

I've created a new Team Project in TFS, but when I try to add my solution to it I get:
'Failed to create mapping
Cannot map server path, $/Finance/MyApp, because it is not rooted beneath a team project.'
I can't find anything on google or here that looks remotely like this problem.
I had this issue when using Microsoft's Team Foundation Service from Visual Studio 2012. I had just created the new team project via the TFS website. Although I could see my new project in the 'add solution' window, I got the error the OP reported.
I had to go into the "Team Explorer" window, then into "Connect to Team Projects" and tick the new project. Then I was able to add my solution to the team project.
Is Finance a team project for you?
If not, you can clear the mappings for the workspace or even just delete your workspace.
http://msdn.microsoft.com/en-us/library/54dkh0y3(v=VS.100).aspx
Had the same issue when upgrading project to TFS 2010 from 2008. The solution was to delete the vsssc file in the root of the project folder and re-add it
In my case I had to do Team Explorer and connect to the new project
then I had to close my solution and re-open and then the "add to source control" worked.
--Connect and check project in team explorer window
--Close solution
--Open solution
--retry adding solution to source control
I had this issue with Visual Studio Online's source control, Visual Studio would not recognize the team project even after connecting to team projects, refreshing, restarting Visual Studio. I had to use the "Open in Visual Studio" link from the project on the Visual Studio Online site and then open the solution from there.
Well, i didn't want to do anything so drastic, it turned out that one of my subfolders inside the solution i wanted to add to source control, was mapped inside a different workspace (on a different TFS server). So the solution was to connect to that other TFS server, find and delete the conflicting folder mapping inside that workspace, and try again.
I had the same problem using visual studio 2008 and TFS 2012. In my case, when I manually added the local folder to the project through the workspace mapping, the problem went away.
File -> Source Control -> WorkSpaces -> Edit
Then when I went to add the solution to source control it detected the mapping automatically.
In my case, I copied the folder from "My Documents" to c:\tfsroot where I had mapped the TFS Root. Then when I opened the solution and added it to TFS it worked.
I had the same problem. My solution in VS2017:
Open Team Explorer tab
Select Source Control Explorer
Right click on the top level folder for the project and select "Advanced/Remove Mapping"
Remove the Mapping
Right click on the top level folder for the project and select "Advanced/Map to Local Folder"
Browse to the top level folder with the source code (You may need to adjust the path you selected. It may append a folder name to the end)
Click "Map"
Answer "Yes" to Message Box "Newly mapped items will not be downloaded until you execute a get. Do you want to get $/YourFolderName now?"
That should do it!

Resources