Associating a solution with an SCC provider

I am putting together a Source Code Control package in C# with the Beta 2 SDK.  I am having some difficult getting a solution associated with my SCC package so that when the solution is opened VS will load my SCC package.

I have followed, as best I can, the documentation in the "Registering a Source Control Package" topic in the VSIP help.  However, it says "Source control packages must implement the IVsSolutionPersistence to enable automatic solution-based package swapping".  It seems the IVsSolutionPersistence is not the correct interface.  The samples are using  IVsPersistSolutionProps and IVsPersistSolutionOpts.  I have implemented these as best I could from the C++ sample.  Still no luck.  The best result I get is that the solution will load but VS reports that it cannot find the source control provider associated with the solution.

The sub-section "Automatic Solution-based Package Swapping" describes, in general terms, how this is supposed to work.  But it does not specify how to implement it or what exactly VS is checking/expecting/doing for this to work.

Any ideas   Are there any other sources of info on this

Thanks


Answer this question

Associating a solution with an SCC provider

  • Russ Monckton

    Hi All,

    I'm writing in this thread of conversation because I pretty much have a similar problem.

    I am also trying to write a Source Control Package using C#. I have been taking help from the sample code that comes with SDK 2005 documentation. The sample code 'SccPkg' has been written in C++. Furthermore, this sample code implements interface IPackage.

    I created my package by using the wizard to create extensibility package. I did not have to implement IPackage. Then I added my own toolbar and menus. I also implemented the interfaces IVsQueryEditQuerySave2, IVsSccManager2,IVsSccProvider,IVsSccManagerTooltip,IVsPersistSolutionProps. I created the registry entries as described in the SDK documentation and Smaple package(Creating a Source Control Package). When I launch the DevEnv Hive, I can see my package under Tools->Options->Source Control. The problem I am running into is that I can not choose my package from this list. I tried to debug it and I found that on selecting my package from the list, the package function 'Initialize()' is called.

    I can successfully pick 'Versioning Integration Sample', but not my package. Would anybody have any ideas about what I might be doing wrong

    Thanks a lot



  • vmadan16

    Hi Kevin,

    "By "choose add to source control", I assume you mean associating the project with my SCC provider in Tools | Options | Source Control. "

    Sorry, I should have been more explicit, by choose add to source control, I meant to say choose File | Add to Source Code Control on the menu after opening a new project.  Are the functions called in that scenario


    much appreciated,
    mike


  • Ted Wagner

    Hello,

    is your implementation of IVsPersistSolutionProps::ReadSolutionProps getting called for your SCC package   Also, do you have entries from your scc package written out to the solution file i.e.

    GlobalSection(SccSample) = preSolution
      SccSample = SccSample
     EndGlobalSection

    Do you get the error after msenv call into ReadSolutionProps that it can't find the source code control provider associate with the solution

    much appreciated,
    mike

  • Yaachiru

    Hi Kevin,

    I think it might be best if I could possibly repro this situation to where it is throwing the earlier error regarding how it cannot find the source control provider associated with the solution.  I can backtrack and see what it is trying to do at that point.  If possible you can send me your SCC package via mail mikewong@microsoft.com along with steps to repro.  I also understand how it might not be possible to send because of other dependencies but I believe we can make sure progress if I can see it firsthand in a debugger setting.

    thanks!
    mike


  • melody45

    Sorry Kevin for the late reply,

    lets take it scenario by scenario - if you open a new project, then choose add to source control, then File | save all to force the save to the solution. We should see at least a call to your IVsPersistSolutionProps::QuerySaveSolutionProps.  Here is the actual call

    if ((SUCCEEDED(pPackage->QueryInterface(IID_IVsPersistSolutionProps, (void **)&pPersistProps))) && (pPersistProps != NULL))

    {

    HRESULT hrSave = NOERROR;

    VSQUERYSAVESLNPROPS qsspSave = QSP_HasNoProps;

    if ((SUCCEEDED(pPersistProps->QuerySaveSolutionProps(pHierarchy, &qsspSave))) && (qsspSave != QSP_HasNoProps))

    hrSave = pPersistProps->SaveSolutionProps(pHierarchy, (IVsSolutionPersistence *)pPersistence);

    If you can successfully get the entries added to the solution file, the next step will be to make sure that the "MyScc" is registered under
    HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0Exp\SolutionPersistence\MyScc
    The default key should point to the SccPackage GUID.
    where 8.0Exp depends on where you are registering your Source control package.

    Now, if we open the solution, the shell gets the package from the key and calls readsolutionprops.  That is where you'll set the active provider. 

    As a side note, in the SccSample if I add the solution to source control and close the solution without saving, I can get it into a state where the  .sln presolution SccSample setting doesn't exist but when I reopen the solution, the source control glyphs appear in solution explorer.  The sample is setup so it stores in C:\Documents and Settings\profilename\Application Data\Personal Version Store so when the C# project system looks for the glyphs, it finds the filename in the version store, etc...

    I will try to find more documentation but I would be interested in the results above.


  • asmana

    File | Add to Source Control is not available in the menu.  (It should not be until you have selected an scc provider in Tools | Options)  I am writing my own scc provider -- we'll have our own File | menu.

    When we associate the solution using the Tools | Options | Source Control with our vs package, then Save All.  The correct methods are called, QuerySaveSolutionProps() and WriteSolutionProps() is called.  However, nothing is ever written to my .sln file.  The code from my WriteSolutionProps() method is in this thread a few posts back.

    I'm just wondering why the solution file is not updated.  What could I be missing

    I am using VS 2005 beta 2 with the August CTP VS SDK.

    Thanks

  • Gary D

    Does anyone have any more info on the situation above
  • GapIT

    Thanks for replying.
    By "choose add to source control", I assume you mean associating the project with my SCC provider in Tools | Options | Source Control.   When I do this, save, then close the solution (it has two projects in it) the following methods are called:
    SetActive()
    WriteSolutionProps()
    OnQueryCloseSolution()
    OnQueryCloseProject()
    OnQueryCloseProject()
    OnBeforeCloseSolution()
    OnQueryCloseProject()
    OnBeforeCloseProject()
    OnQueryCloseProject()
    OnBeforeCloseProject()
    OnAfterCloseSolution()

    As you can see niether QuerySaveSolutionProps nor SaveSolutionProps are called.  Is there a call or interface implementation I am missing during init or SetActive   Perhaps how my package is registered The HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0Exp\SolutionPersistence\MyScc
    key seems correct.  The "MyScc" (the package name) is supposed to match what specifically   The value of Default for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp\SourceControlProviders\<myGuid>   I've seen documents that refer to the "package name", but I have not found a referece that specifies where this is actually set.

    Side question: Does the class which implements the scc package and profers the SCC service have to be the same class which implements the SCC service interfaces   I would imagine, no, but I have found no specific docs. (though the sample does it that way)

    Thanks again!
    Kevin

  • Piotr Trochimiuk

    Thanks for responding.

    No, IVsPersistSolutionProps.ReadSolutionProps is not getting called.  The entries in the solution are not being written.  How and when to do this is unclear to me.  I have been unable to decypher what to call and when.

    My implementations for IVsPersistSolutionProps.SaveSolutionProps() and IVsPersistSolutionProps.WriteSolutionProps() are not getting called unless I add a call to IVsSolutionPersistence.SavePackageSolutionProps().  Even then, the .sln file is not updated.

    WriteSolutionProps contains the following (based on what I found in the C++ SCC sample):
    public int WriteSolutionProps(IVsHierarchy pHierarchy, string pszKey, IPropertyBag pPropBag){
                string s = "MyScc";
                object o = (object)s;
                pPropBag.Write("MyScc", ref o);

                return VSConstants.S_OK;
    }

    For any SCC package I would imagine this process would be the same. (i.e. the calls to get the packge info in the .sln and when/where to use them)  Any idea what the process is   Know where this is documented  

    Thanks,
    Kevin


  • Associating a solution with an SCC provider