tags:

views:

387

answers:

2

I'm writing a check-in policy for Team Foundation Server, and would like to know if there's any way to get the path to the project solution's .sln file with the TFS SDK. Seems like there should be a way, just haven't found it yet--any help would be appreciated.

+1  A: 

Which .sln file? A single Team Project may have more than one.

If you want to get the path to the current solution while Visual Studio is running, then you can use the Visual Studio SDK to do that.

John Saunders
I'm looking for the solution file (or solution files, if a lot is being checked in at once) for whatever project is being checked in at the time.
DashRantic
A project may be included in multiple solution files, or in none. It's not a simple parent/child relationship.
John Saunders
A: 

Found what I needed:


// Enumerate the checked pending changes.
PendingChange[] changes = m_pendingCheckin.PendingChanges.CheckedPendingChanges;

foreach ( PendingChange change in changes )
{
    // this contains the full local path to whatever is being checked in
    // can use this to find the solution file
    change.LocalItem;
}

(m_PendingChecking is of IPendingCheckin type)

DashRantic
Glad that works for you. For others reading this: keep in mind there may be more than one solution file, and not necessarily in the parent folder of the project folder.
John Saunders