[Mono-dev] Is it possible to use .NET TeamFoundation libraries on Linux mono?

CodeSlinger dkolb at emdeon.com
Sat Jan 1 16:42:22 EST 2011


Well I was not so far able to use the actual .NET 4 assemblies on Linux mono
but I did get the below app, that gets the latest changeset for a branch,
working on both Windows and Linux, using the opentf libraries. Sure would
like to see the openrt libraries get updated since they do not support the
newer classes and signatures (see my comments).

The below code runs on both systems if reference the openrt assemblies.

using System;
using System.Net;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace GetTfsChangeset
{
    class Program
    {
        static void Main(string[] args)
        {
            string lPath = "$/MyBranch/Main";

            //string lServer = "MyServer.com"; // this works in Windows but
not in Linux
            //string lServer = "http://xxx.xx.xx.xxx:8080"; // this works in
both
            string lServer = "http://MyServer.com:8080"; // this works in
both

            // all of these work on windows and indeed fails if pw is bad -
are supposedly obsolete though! Linux needs the last one with the domain!
            //TeamFoundationServer tfs = new TeamFoundationServer(lServer);
            //TeamFoundationServer tfs = new TeamFoundationServer(lServer,
new NetworkCredential("user", "password"));
            //TeamFoundationServer tfs = new TeamFoundationServer(lServer,
new NetworkCredential("user", "password", "domain"));
            //VersionControlServer vcs =
(VersionControlServer)tfs.GetService(typeof(VersionControlServer));

            // this does not work with the openrt libraries - mismatch of
parameters - and does not give obsolete errors on Linux
            TeamFoundationServer tfs =
TeamFoundationServerFactory.GetServer(lServer, new NetworkCredential("user",
"password", "domain"));
            VersionControlServer vcs =
(VersionControlServer)tfs.GetService(typeof(VersionControlServer));

            // this is the newer way to do it but the class is apparently
not avail in the Linux openrt libraries
            //TfsTeamProjectCollection tfscoll = new
TfsTeamProjectCollection(new Uri(lServer), new NetworkCredential("user",
"password"));
            //VersionControlServer vcs =
(VersionControlServer)tfscoll.GetService(typeof(VersionControlServer));

            // get the changesets - currently stops after one which should
be the latest
            IEnumerable changesets = vcs.QueryHistory(lPath,
VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 1, false,
false);

            Console.WriteLine("Changesets for path '{0}'.", lPath);
            foreach (Changeset changeset in changesets)
            {
                Console.WriteLine("Changeset id {0}, Comment '{1}'.",
changeset.ChangesetId, changeset.Comment);
            }

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
    }
}


-- 
View this message in context: http://mono.1490590.n4.nabble.com/Is-it-possible-to-use-NET-TeamFoundation-libraries-on-Linux-mono-tp3170015p3170471.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list