How to find files in source control but not in a Visual Studio solution? - visual-studio

I have a rather large Visual Studio 2008 solution in Subversion. It was migrated from Visual SourceSafe a few months ago. I'm starting to find that there are a number of files still in source control that were removed from the solution back when I was using VSS. They were probably renamed or deleted after they were checked out - VSS doesn't like that.
I'm looking for an easy way to find all of the files that are not in the solution but are in Subversion. Something like WinMerge's folder compare would be ideal, where one side is the Subversion working copy and the other side is the project contents.

We haven't upgraded to VS2008 yet, so I'm not sure how much of this applies, but anyway:
Approach 1: On the Solution Explorer toolbar, click "Show All Files." Then highlight the root node of the solution and hit "*" on the numeric keypad to fully expand the tree. The icons that are just outlines are files that aren't part of the solution. From those, you have to determine by hand which are unnecessarily in svn.
Approach 2: Do a "svn export" to create a secondary copy of the project somewhere. Open the new copy with VS and then choose File->Source Control->Change Source Control. In the resulting window, if any projects show as "Connected," highlight them and click "Disconnect" on the toolbar. Close the Source Control window and then, in the Solution Explorer, with "Show All Files" turned OFF, delete everything. The files remaining on disk are the extras your project is no longer using.
With both approaches, it would be smart to make a separate backup copy of the project before doing anything, just in case you nail one too many files.

Related

Some projects not showing TFS Menus

I have 8 projects in my solution. 3 of them are not showing any TFS menus when I right click on the project or any of the files from Solution Explorer. They are in TFS though, if I go through the Source Control Explorer I can manually check them out/in. Also those 3 projects do not have associated .vspscc which the other 5 projects do. Something must have got messed up but I am not sure what. How can I fix this so that I get those TFS options back in Solution Explorer. Having to manually check out/in is not practical.
edit: I've tried wiping my local copy and bringing the solution down from source control again. I've also removed those projects from the solution and re-added them which did not work.
It sounds like 3 of your projects have lost their source control bindings. You should be able to restore them easily. Just go to the Change Source Control dialog, which will allow you to set the source control bindings for all the projects in your solution:
File > Source Control > Change Source Control...
Then you'll need to enter your TFS server name and the server path for the projects that have lost their bindings.
Edward got me pointed in the right direction, for me it was an issue of TFS having gone offline.
Resolution: I selected the Solution level in Solution explorer, then went into File>Source Control> and selected the Go Online menu option, which restored all of my right click TFS menu options.

Visual SVN client commit solution files only

I have VisualSVN client integrated in my Visual Studio and I want to commit modified files. The problem is when I right-click on the solution file item in the solution explorer and choose 'Commit', VisualSVN is trying to commit all modified files in my trunk. This is the same problem if I choose 'Commit' from the VisualSVN menu item.
Is it possible to just show the modified files linked with my solution and not all the trunk files?
I know that with AnkhSVN, this works perfectly but I think I missed something with VisualSVN client.
Use VisualSvn menu or context menu in Solution Explorer and choose "Show Changes". It could also be that you have fiddled with the VisualSvn->"Set Working Copy Root" option. Set it back to automatic mode if possible.
As VisualSvn uses TortoiseSvn in the background, it works only with folders so if there is a modified file in the folder not belonging to the solution side by side with a modified file belonging to the solution you will see both files.

How to have TFS 2010 detect changes done to files outside of Visual Studio?

I'm using Team Foundation Server 2010 with Visual Studio 2010.
Whenever I modify a file outside of Visual Studio, TFS doesn't seem to detect the change done to the file, and thus doesn't offer me the option to check-in the file after it has been modified.
How can this be solved?
TFS has a "Reconcile" command for this:
Open the Source Control Explorer
Right-click on the folder with the changes and choose Compare
Select the files you want to reconcile (press CTRL+A to select all files)
Click on the Reconcile button
Set the options in the Reconcile Folder Differences dialog. Make sure Files that do not have pending changes is set to Check Out
Click OK
If you have local changes the Check Out dialog will be shown. Set the preferred Lock type
Click Check Out
See also: Reconcile differences between folders
If you have a network connection to your server while you're working outside of Visual Studio, it's probably best to go ahead and check the file out before editing it, either using the tf command line client, or using the Windows Explorer shell integration that's available in the TFS Power Tools release. (Plus an increasing number of other tools have TFS integration that makes this automatic, but if you're just using notepad, this still needs to be a manual step.)
Of course, there are many times when you're working and you don't have a network connection available that allows you to check out the files.
If you know what files you've modified, you can just check them out from within Visual Studio, then you'll be able to check them back in.
If you don't know what files you've edited, you can detect the changes by running the tfpt online command (also part of the Power Tools release). This will locate the files that have been modified locally and check these files out from the server.
This worked for me, using the TFS Power Tools:
tfpt online /adds /deletes /diff /noprompt /recursive directory-name
(where directory-name is the path to the directory to be updated, otherwise it will detect changes throughout your entire TFS repository)
If you want to know what it would do without it actually making any changes, you can force it to do a dry run by adding the /preview switch.
*1- make changes outside of Visual Studio
2- go to Visual Studio and open Source Control Explorer
3- right click on the folder > "Check Out for Edit" > "Check Out"
4- right click on the same folder > "Undo Pending Changes..." > "Undo changes" > "No to All"*
I tested this workaround on a branch and it helped me a lot. But there are only new files and new folder who has to be done manually.
I recommend to create a branch before the operation. It isolates you the time of the operation.
Note: This technique does also the files identical cleanup that TFS always marks as modified.
Try this. It's some sort of workaround, but it works:
make changes outside of Visual Studio
go to Visual Studio and open Source Control Explorer
right click on the folder > "Check Out for Edit" > "Check Out"
right click on the same folder > "Undo Pending Changes..." > "Undo changes" > "No to All"
That's it. The changes are visible now.
There's also another solution to get TFS to figure out the files that have changed outside of Visual Studio:
Open the solution offline
In Solution Explorer select the solution file and then press the Go Online button ()
TFS will automatically scan the solution for changes after this.
Step one can be achieved in a number of different ways. Here are some:
Use the GoOffline Extension - very simple and effective.
If you're asked for TFS credentials when opening the solution (no automatic domain auth), then don't enter the credentials. The solution will open offline and you'll login after pressing the Go Online button
(extreme solution) Disconnect your network cable; Open the solution; Connect the network cable.
Visual Sourcesafe works like this too and the way I get VSS or TFS to notice the change is by checking the file out once inside Visual Studio.
Open Source Control and go to your TFS folder. Right-click on the folder and choose 'Compare'.
Notice that your edited files show up marked in red.
I find this is better than tfpt online which also gets you files that are not readonly and not edited.
I had this problem in the past, when my Internet was down and I worked offline, and most of my changes didn't appears in Team Explorer.
Following these steps:
First, In the solution explorer, select the folder that you want to re-conciliate (for me, it was my entire solution folder), and select Compare...
Click in Modify Filter, and in the filter text-box, you could type:
*.cs;!obj\;!bin\;!packages\;
In this example, it will include in the search only C# files and exclude in the folders: bin, obj and packages.
Notice the column Pending Change has the info whether the file is marked as edit, add, etc... or nothing...
To mark as edit (when the local item has a matching server item), select the file and choose Check out for Edit...
To mark as add (when the local item doesn't have any server item), select the file and choose Add Files
Finally, I am not sure why the projects are not listed here (after I remove *.cs filter, still doesn't show up), so rebuild the solution to make sure the projects updates as well
+ In the solution, click the connect button (if shows up) that said Go Online.
I found that in Visual Studio 2015, with the project open, Visual Studio discovered for itself that files had been modified externally, and automatically checked them out without me having to do anything. Checking in the project in the normal way saved the external modifications.
In my case, the following worked (at least the one time I tried it):
Go to the Pending Changes panel
Select View Options under either Included or Excluded changes.
Switch between Show All and Show Solution Changes
Switch back if desired
Changing the View Option appears to force a refresh of modified files.

Is there a way to drag & drop to copy files between two visual studio instances?

Is there a way to copy files between two Visual Studio 2008 instances ? A plugin, setting, or something else ? Currently, dragging a file from one instances to another does nothing (mouse shows that it's invalid operation).
Right-clicking a file and selecting "Copy" from instance 1, and pasting in instance 2 results in the following error:
The source files for this operation cannot be found in this solution.
Any ideas or solutions ?
About the only way you can do that, is to right-click, Add Existing Item and browse for the file. Ridiculous, I know, but thats the way it is ;)
Got me the Visual Studio extension Open In Explorer that provides a context menu option "copy files". This way you don't have to go over a windows explorer window.
Very frustrating, I know.
The thing is that if you copy it directly to the file system, it may not be included in the TSF.
My advice is:
Copy, or drag the files from the file system (i.e. Windows Explorer)
Paste, or drop them in the Visual Studio Solution Explorer
Worked for me :-)
The simplest built-in way I have found (for VS2019) is:
Right click on the source file
Select Copy Full Path
Switch to the destination solution/project
Right click on the destination folder
Select Add -> Existing item
Paste
Click OK
This will copy the file from source to destination. (Leaving the original alone).
I prefer this as it avoids any tedious browsing through folders.
There's no direct way. One way would be to right click on the folder in the solution explorer, open the folder in explorer, then drag from there into the other instance of Visual Studio.
Just add your source project to your target solution. That will allow you to copy/paste between the two instances of Visual Studio. This works because Visual Studio's clipboard data for copied files must have a representation that's relative to the project identifier.
Futhermore, once you've added the source project to the target solution, you don't even need to copy between instances, because your source project is in the same solution you're copying to. You can probably even CTRL+drag files to copy them so you don't lose text in your clipboard. When you're done, you can remove the project. This is far simpler than opening multiple explorer windows, copying file, clicking 'show all files' in solution explorer, and manually adding the new files.
When your source project is not in your target solution and you try to copy files between instances, you'll get an error like this.
This does not occur when your source project (in one instance) is also in your target solution (in another instance) of Visual Studio. Once you understand what's happening, you'll do a face palm, because the error is literally telling you what the problem is.
Go to file explorer then which files do you want to put in your project, just select them. Now copy those files and paste them on to project. You can also past folders with sub folders and files into project.

Hidding source control files within Visual Studio's solution tree

We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named ".MySCMServerInfo" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We also have several WAPs (Web Application Projects) that we develop. All these .MySCMServerInfo files show up in the solution tree and the Pending Checkins window when they should not. There has to be some way to force VS to ignore files of a given extension because it ignores .scc files. How do I get VS to ignore .MySCMServerInfo files within a WAP?
I have new information about this issue. Setting the hidden bit on .MySCMServerInfo file causes Surround SCM to loose track of the modification state for files. It starts thinking files are out-of-date when they are not, and it always attemps to get new versions.
Instead, set this registry key if you're using Visual Studio 2008:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\
{8FF02D1A-C177-4ac8-A62F-88FC6EA65F57}\IgnorableFiles\.MySCMServerInfo]
Set this registry key if you're using Visual Studio 2005:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\
{8FF02D1A-C177-4ac8-A62F-88FC6EA65F57}\IgnorableFiles\.MySCMServerInfo]
These will tell Visual Studio to not display .MySCMServerInfo files within the Solution tree and the Pending Checkins view.
Using the file system hidden bit should work.
Late Answer but hopefully useful to others.
I began experiencing this problem when using Visual Studio 2015 with the new ASP.Net 5 Project templates. (I presume this is because the new templates automatically include everything in the folder rather than only showing the things that are listed in the project file).
Showing these files in the Solution explorer change be prevented by right clicking the file and selecting "Hide from Solution Explorer" but this didn't prevent SCM from including them in the Pending Check-ins Window.
The correct way to deal with this problem is:
Select the file(s) in Solution Explorer
Select the File > Source Control > Exclude from Source Control
Reference
NOTE: Right Click in the Solution Explorer DOESN'T have this option.

Resources