Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to TfsTeamProjectCollectionFactory.GetTeamProjectCollection taking ICredentialsProvider

According to the MSDN the method GetTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentialsProvider fallbackCredentialsProvider of the TfsTeamProjectCollectionFactory class is now deprecated:

  • "Note: This API is now obsolete."

  • [ObsoleteAttribute("This method has been deprecated and will be removed in a future release. See GetTeamProjectCollection(RegisteredProjectCollection) instead.", false)]

The advice is to use the overload that only takes the RegisteredProjectCollection, but what should we use from now on if we want a fallback mechanism for credentials?

Thanks

like image 952
gabrielmaldi Avatar asked Jan 01 '13 04:01

gabrielmaldi


People also ask

What is class factory for tfsteamprojectcollection objects?

Class factory for TfsTeamProjectCollection objects. The TfsTeamProjectCollectionFactory type exposes the following members. Gets the TfsTeamProjectCollection instance that is associated with the server at the specified URI. Gets the TfsTeamProjectCollection instance that is associated with the specified RegisteredProjectCollection instance.

Is tfsteamprojectcollection thread safe?

It caches TfsTeamProjectCollection objects without regard to credentials. Cached objects are indexed only by server uniform resource identifier (URI). Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

How do I delete a team project in TFS?

Use the Project Creation Wizard in Team Explorer to create a project or the Team Project deletion tool to delete one. That error message isn’t helpful when you already have a team project with this name and only the TFVC project folder is missing. To fix this, you’ll need to use the TFS client OM.

How to destroy a TFVC team project folder?

TF.exe makes it easy to destroy a TFVC team project folder, but if you do it’s not as easy to recreate it. You can destroy all TFVC data in a team project by running tf.exe destroy $/<projectName> Then if you try to navigate TFVC in a web browser, you’ll see an error like this:


1 Answers

You need to use the new TfsTeamProjectCollection constructor along with this TfsClientCredentials constructor which allows interactive prompts for authentication.

// Use default windows credentials, and if they fail, AllowInteractive=true
var tfsCreds = new TfsClientCredentials(new WindowsCredential(), true);

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
    new Uri("http://yourserver:8080/tfs/DefaultCollection"),
    tfsCreds);
like image 158
Grant Holliday Avatar answered Oct 18 '22 20:10

Grant Holliday