Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 Not Recognizing proper Source Control Plug In

I work on different projects that use different source control providers. Subversion, Git, TFS, etc...

To work on Subversion, I've installed AnkhSVN. To work on Git, I've installed the Git Source Control Provider To work on TFS, ...well, you get the idea.

The source control information is saved as part of the solution file.

Yet, invariably, when I open a new project, Visual Studio keeps using whatever the last source control provider selected was. It doesn't seem to pick it up from the solution file. I always have to open the Tools > Options dialog to switch providers (which takes FOREVER!)

Is this something I am doing wrong? I would expect Visual Studio to change providers based on the solution that is open.

If this is something Visual Studio simply doesn't do, is there a macro or extension out there that will automatically figure this out?

I can't believe this question hasn't been asked before, but I didn't see any obvious dupes in the StackOverflow list of "Questions that may already have your answer." Which, sadly, seems to point to the answer of "it's just me."

like image 409
CleverPatrick Avatar asked May 28 '12 13:05

CleverPatrick


People also ask

How do I add a project to source control in Visual Studio?

a Select the project (not the solution) in the Solution Explorer pane. b Select Add Selected Projects to Source Control. To add a project to source control without placing the solution under source control: a Right-click the project in the Solution Explorer pane and select Add Project to Source Control.

How do I add a project to source control in Visual Studio 2019?

If you go into Source Control Explorer and navigate to your project you should see that LibraryTests isn't included. Right click on the folder, click on "Add items to folder..." then click on your project folder thats missing. Click next and this should add it to source control.


2 Answers

The per solution provider binding is, IMO, wrong as the solution can be resident in multiple source control systems. The trick is to load the proper source control provider checking reserved directories in a pre-load solution event of a VS extension. The core code is as it follow:

IVsRegisterScciProvider vsRegisterScciProvider = GetService<IVsRegisterScciProvider>();
vsRegisterScciProvider.RegisterSourceControlProvider(sccProviderGuid);

The full code for such an extension is here. I may release it shortly after a bit of testing as it's very simple, even if it required me a lot of research. I couldn't find anything similar around and it's strange to me as it should be the obious way to do it. The documentation about RegisterSourceControlProvider was also extremely misleading so that may be the reason.

like image 162
ceztko Avatar answered Sep 21 '22 05:09

ceztko


Not really an answer but this was too big to put into a comment:

I hate to say "works for me" but, it does in fact work for me. I'm only using AnkhSVN and the TFS client but Visual Studio switches between the two for me depending on the solution I open. So what you're asking for definitely is "support" to work. Perhaps one of the other plug-in providers has an issue?

Have you opened your solution files and confirmed that the source control information is there? It should look like this:

GlobalSection(SubversionScc) = preSolution
    Svn-Managed = True
    Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection

GlobalSection(TeamFoundationVersionControl) = preSolution
    SccNumberOfProjects = 5
    SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
    SccTeamFoundationServer = http://XXXXX:8080/tfs/XXXXX
    SccProjectUniqueName0 = ...
    SccProjectName0 = ...
    SccLocalPath0 = ...
    <etc>
EndGlobalSection

Also, when you open an appropriate solution, what indication are you getting that it's not switching providers? Do you get an error message, or does your project just not appear bound to source control? In particular, my TFS windows stay open and show wierd errors when I open an SVN solution, but the context menu in Solution Explorer does switch over to the correct provider.

like image 42
Michael Edenfield Avatar answered Sep 21 '22 05:09

Michael Edenfield