How to switch to TFS automatically when solution is loaded? - visual-studio

I have an annoying problem with source control plugins... I'm using VS2012 and I have some projects on TFS and others on SVN (using AnkhSVN).
When I open a SVN solution, VS seamlessly switches to AnkhSVN as the source control plugin, which is fine. But then, when I open a TFS solution, it doesn't switch back to TFS... the most annoying effect is that automatic checkout doesn't work. To fix it, I have to unload the solution, changes the source control plugin to TFS, and reload the solution.
Is this a known problem? Is there a way to fix it?

There is not a good option that I can think of. That part of Visual Studio is designed to work only with one Source Control system at a time and I understand your pain.
I guess my first question is why you need both, but I guess there is some need somewhere. You can see folks with the same problem:
How to quickly switch source control providers in Visual Studio 2010?
Option 1: Virtualisation
As I have a machine capable of running VM's (Windows 8 with Hyper-V) I would have two VM's with one configured for TFS and the other configured for SVN. Not elegant, but it would allow you to switch.
Option 2: Regedit
You can change the setting in the registry.
HOW TO: Change Source Control Providers If Two or More MSSCCI-Compliant Providers Are Installed
So you could have a "key" file for each setting stored on your desktop and:
Close Visual Studio
Run registery key
Open Solution
While ugly and requires remembering it would be the best option locally.
Conclusion
There is no good answer but I do think that the two options above will get you there.

Related

Is there a simple way to check out files in TFS from a Mac environment running Sublime 2?

Ok, before I explain in detail, here's my (very odd) setup:
Hardware: iMac
OS: Mountain Lion
Software:
Editor (Mac): Sublime 2
Virtualization: Parallels Running Windows Server 2008
IDE (Windows): Visual Studio 2010
Source Control (Windows): Team Foundation Server
So here's my dilemma.
I looooove Sublime 2. However, being a Microsoft shop at my workplace, I have no choice but to deal with TFS. I don't do a lot of back-end coding, I'm a front-end guy and don't need all the hefty class and structure tracking built into Visual Studio, so Sublime is perfect for me.
One of the things I love about Sublime is that I can hit cmd+p and pull up any file immediately. The alternative is spending several minutes sifting through our file structure to locate the same file (we have a massive project structure...it's a beast).
Unfortunately, I can't just tap cmd+p and pull up any file...I can...but after editing it, I hit save and "uh oh! file isn't checked out, it's read only". I then have to switch spaces, spend several minutes sifting through directories to locate that same file I worked on, and check it out. Switch back, save, and then check it in. It wastes a lot of my time and defeats the time-saving benefits of Sublime's file searching.
What I'd like to know is if there's an easier way to accomplish this. I've tried a few things and none have panned out. I found a plugin that integrates TFS with Sublime - but that only works for Windows. I tried using Eclipse with a TFS plugin, but I still have to browse through a massive directory structure to check out the file in Eclipse before editing it in Sublime.
Is there any way to streamline this process better? I know it might sound silly to go through such extremes to save a minute or two here & there, but when I do this hundreds of times a day, it starts to save a LOT of time!
Thanks in advance to the community for any help on this!
If you can persuade your TFS Admin team to upgrade to TFS 2012 you will have your solution. TFS 2012 supports "Local Workspace" which does not keep files read-only on disk. You download your source code once through Visual Studio or Eclipse and keep working in ANY editor you want. TFS Client tracks changes on the file system and you just need VS or Eclipse to check-in your work at the end of the day.
For TFS 2008 and 2010 you have to check-out your files manually or with the help of a supported IDE. Those versions only support "server workspace"s and that flavour of workspace keeps all files on disk as read-only.
You might have another chance with 2008 or 2010 tough. TFS 2008 and TFS 2010 on Windows platform supports offline working, which temporarily disconnects your workspace from the server to do your work. Then at the end of the day you go back online and TFS client tries to "detect" what changes were made when you were offline and lets you check them in. This blog post says Team Explorer Everywhere supports offline work. You might need to remove read-only flags of files manually. Offline working is not perfect even on Windows platform and you need to be careful until you get used to it but I believe it is worth giving a shot.
If upgrading to TFS 2012 is an option then you probably want to consider it.
TFS2012 with local workspaces no longer require files to be checked out in visual studio first (files are no longer marked as readonly, and vs detects changes from other programs). This will get rid of one of your alt-tabs to windows.
You'd still have to alt-tab back to check in, you could potentially use a commandline "tf checkin" if you don't want to keep visual studio open.
So after trying several suggestions from here, among a few I found elsewhere, I've come to the conclusion that the best setup (for me) is as follows:
Editor (Mac): Sublime 2
Editor (PC): Sublime 2 with TFS plugin
Virtualization: Parallels Running Windows Server 2008
IDE (Windows): Visual Studio 2010 Source Control
(Windows): Team Foundation Server
So as you can see I updated my existing setup with one slight tweak. On my Windows side, I installed Sublime 2 and installed the TFS plugin. If I want to check out a file, I switch to windows, search for the file, check it out via Sublime's TFS plugin, then switch back to the Mac. It's certainly not ideal, and requires an extra step, but it seems to work the best for me and is faster than using Visual Studio to check in/out.
If anyone comes up with a more elegant setup (aside from using TFS 2012 - which thankfully is coming for my organization), I'd love to hear about it. In the meantime, I hope this helps anyone else who might be using a setup similar to mine.

How to quickly switch source control providers in Visual Studio 2010?

I'm currently working on .Net projects that are using either Git or Mercurial (Hg) source controls. I use Visual Studio 2010 for all of these projects. As I often have to switch source control providers I was wondering if there's a quick way to do this, so I don't have to go Tools -> Options -> Source Control once an hour.
A much better solution would be if Visual Studio would recognize which source control provider it needs or maybe remember which provider was used for a certain project. Can that be done?
With a nudge in the right direction I managed to handle this problem even better then expected - no switching necessary.
For Mercurial solutions I use VisualHG and for Git I use Git Source Control Provider. I also installed HgSccPackage. Now I don't really know how or why this works, but I've got GitSCC selected as the Source Control Provider in the settings, but when I load a Mercurial project VisualHG takes over. All I have to do is set the SCC to VisualHG the first time I open the project, close the project, change back to GitSCC and when the project is reloaded VisualHG will be used for it.
Interestingly it does not work without HgSccPackage installed. If someone can explain this, please do.
Note that it does not seem to work the other way round.
I use Git in combination with VS 2010 by keeping a commandline screen open. I do my work in Visual Studio and when I'm ready to make a commit, I switch to the commandline screen.
If you do this, you can use Git and Mercurial side by side in combination with VS 2010.

How to work offline with TFS

Our TFS server has some temporary connectivity issues right now, and as such VS has gone unresponsive, leaving 50+ developers unable to work!
Is it possible to switch TFS into an offline mode in the event of such an issue?
See this reference for information on how to bind/unbind your solution or project from source control. NOTE: this doesn't apply if you are using GIT and may not apply to versions later than VS2008.
Quoting from the reference:
To disconnect a solution or project
from source control
In Visual Studio, open Solution
Explorer and select the item(s) to
disconnect.
On the File menu, click Source
Control, then Change Source Control.
In the Change Source Control dialog
box, click Disconnect.
Click OK.
The 'Go Offline' extension adds a button to the Source Control menu.
https://visualstudiogallery.msdn.microsoft.com/6e54271c-2c4e-4911-a1b4-a65a588ae138
plundberg: The "disconnect" button is only available for the TFS provider starting in VS 2008. Even then, I'm not sure if it's officially supported. The recommended way to use the Go Offline feature is to [re]open the solution.
Martin Pritchard: if you get stuck mid-operation, you can force VS to timeout by pulling the network plug (literally) or running ipconfig /release.
Once you're marked offline, here's a step by step guide to working in that mode: http://teamfoundation.blogspot.com/2007/12/offline-and-back-again-in-vs2008.html
More detailed info on tweaking the behind-the-scenes behavior:
http://blogs.msdn.com/benryan/archive/2007/12/12/when-and-how-does-my-solution-go-offline.aspx
http://blogs.msdn.com/benryan/archive/2007/12/12/how-to-make-tfs-offline-strictly-solution-based.aspx
There are couple of little visual studio extensions for this purpose:
For VS2010 & TFS 2010, try this
For VS2012 & TFS 2010, use this
In case of TFS 2012, looks like there is no need for 'Go offline' extensions. I read something about a new feature called local workspace for the similar purpose.
Alternatively I had good success with Git-TF. All the goodness of git and when you are ready, you can push it to TFS.
Depending on which tool windows you have open, VS may or may not try to hit the team server automatically when it starts up.
For best results try this:
Close all instances of visual studio
Open an empty visual studio (no project/solution)
See which windows are opened by default, if source control explorer or team explorer or any other windows that use team are opened (and activated) by default, close them or switch them to a background tab.
Close visual studio
You should notice now that you can start visual studio without it trying to hit the TFS server.
I know its just an aside to your problem, but I hope you find this helpful!
If you have a solution open, and TFS is down, you might have trouble going into offline mode. If you close and reopen your solution, a nice little dialog will appear asking you if you want to Go Offline.
Alternatively if you don't want to close/reopen the solution, (as suggested by Bernie) you can install the TFS Go-Offline plugin, then click:
TEAM -> Go Offline
Simply, change the root folder name for your solution in your local machine, it will disconnect automatically.
I just wanted to include a link to a resolution to an issue I was having with VS2008 and TFS08.
I accidently opened my solution without being connected to my network and was not able to get it "back the way it was" and had to rebind every time I openned.
I found the solution here;
http://www.fkollmann.de/v2/post/Visual-Studio-2008-refuses-to-bind-to-TFS-or-to-open-solution-source-controlled.aspx
Basically, you need to open the "Connect to Team Foundation Server" and then "Servers..." once there, Delete/Remove your server and re-add it. This fixed my issue.
If the code has already been checked out by the user that if offline and they have the latest version on their local hd, then they just need to browse to the solution location and open the solution by double clicking sln file. The solution will open in disconnected mode.

Getting Visual Studio to ignore source control bindings in a solution

Is there a way to tell Visual Studio 2005 to just ignore source control binding when opening a solution? I sometimes need to load a solution for which I don't have access to the source control server, but Visual Studio insists on trying to connect anyway, meaning I have to click "temporarily work offline in disconnected mode" for every project in the solution (of which there are about 20) as it loads. For some reason, it also tries to check each project out immediately after I've told it to work offline, so I have to click past that dialog box too.
As I will never need to edit anything in this solution, is there any way I can open it and have Visual Studio just ignore the fact it has source control bindings in it?
Edit: Ideally, I'd like a way to do this without having to change the project/solution files. They change fairly frequently, so I'd have to redo any changes every time there was a new version (otherwise I'd just unbind them once and it wouldn't be a problem).
Thanks for the replies so far.
The source control bindings are stored in Visual Studio solution file (.sln). For TFS for example, it contains a global section for TFS information and the solution projects added to TFS. You can edit the solution file to remove these bindings manually. I would suggest making a copy of the solution file first. However, I would recommend removing bindins via Visual Studio. Open your solution and go through the offline scenario. Then go to File/Source Control/Change Source Control (VS 2008) to bring up the UI that shows you the source control bindings in your solution. There you can manage the bindings including unbinding them. Once unbound, the next time you open the solution, VS should not have a need to access the source control.
I've been looking for a way to disable Integration between SourceSafe 2005 and Visual Studio 2008. We are forced to use SourceSafe being in a corporate environment and all. SourceSafe is fine on its own if you treat it like a baby. As soon as you try to do anything approaching useful it starts to break. God forbid you try to use the integration with Visual Studio. Being that I didn't want the "Bindings removed" so that it doesn't confuse other devs on the team I needed to be able to tell Studio to ignore the solution and project bindings and continue on it's merry way.
I followed the registry hack suggested in the following post
Removing SourceSafe Integration from Visual Studio 6
Studio did what I wanted...sort of. It removed the SourceSafe integration. However when I opened up a source controlled solution it asked me if I wanted to remove the bindings.
"the projects will be treated as not under source control"
No I don't want you to remove the bindings from the files, I want you to IGNORE them. This dialog pops up every time you open the solution/project file and there is no way around it.
My solution at the moment seems to have worked...for now.
File->Source Control->Change Source Control...->Disconnect
I hope this helps anyone else in the position of having to use SourceSafe but can't remove the bindings from the files themselves. WHY, Microsoft, WHY would you put the bindings in the files themselves?
/rant

Removing SourceSafe Integration from Visual Studio 6

Recently, the SourceSafe integration into visual studio has started to perform badly because we have moved, and the SourceSafe "server" is located across a VPN which goes across a slow connection. This has made loading large projects in visual c++ 6 take 5+ minutes because it has to talk to the "server" for each project. Also, there are some bugs that are dangerous in the integration (the auto-checkout of certain shared projects will do a get latest on the wrong version of a branched file). This has caused me to want to disable the SourceSafe integration, however I have not found any menu option or uninstall option. Google has reported a few registry tweaks, but none of them seemed to work.
Does anyone know of an easy way to remove the SourceSafe integration from Visual C++ 6, without uninstalling SourceSafe altogether?
From http://support.microsoft.com/kb/236399:
Source code control software, such as
Microsoft Visual SourceSafe, that
integrates with the Visual C++
integrated development environment
(IDE) can be configured to connect to
a source code server during Visual C++
startup. In such cases, a loss in
network connectivity will cause Visual
C++ to start up very slowly. To
improve performance, either ensure
proper network connectivity or disable
the source code control software
integration with the Visual C++ IDE.
To do the latter, quit Visual C++, and
then use RegEdit.Exe to locate the
following registry key and set its
Disabled value to (DWORD) 0x00000001:
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Source Control\Disabled
I followed this and it seemed to work upon trying it again. I think I might've had a second copy of visual studio running when I did it the first time.
Open the .dsp and .dsw file in a text editor, and remove the respective entries from the .dsp and the .dsw file. Also, delete the .scc files.
There is a Microsoft Knowledge Base article about how to do exactly this.
The gist of it is that you must manually edit the .dsw and .dsp files in a text editor, and remove a few other files lying around. See the article for more details.
If the solutions mentioned above fail for you do this:
Rename folder: \Program Files\Microsoft\%vs%\Common7\IDE\VS SCC
VS will complain once about plug in not being there and you say "Yes" to ignore it in perpetuity.
All files “got latest,” “read only,” and edited in VS, will make VS complain and offer to “override”, which works fine for me.
What do you gain:
Open VSS-linked solutions quickly without VS matching contents to VSS server.
Open VSS-linked solutions and EDIT the files at will without being bogged down in “check out” bs.
This makes using other distributed source control system on top of project tree with VSS bindings painless.
VSS client still works by itself just fine, including diff, checkout, checkin.
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Source Control\Disabled
I followed this and it seemed to work upon trying it again. I think I might've had a second copy of visual studio running when I did it the first time.
Its working .....Thanks Ajay
What has worked for us, and is much easier, requires no registry/file editing by hand, and safer I think is this:
1) Exit Visual Studio completely.
2) Disconnect from the network (unplug the cable and turn off wireless, or disable the network adapters)
3) Open the VS6 workspace (DSW) for the project. When it starts up it will find it cannot connect with the VSS database it wants to and ask you about that...
4) Tell VS to never try to reconnect to the source control db in the future.
5) Done... VS does all the changes to THAT WORKSPACE/PROJECT setup for you. You are not disconnecting VS from source control in general (like a registry edit would do) and your not manually editing files.

Resources