Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 54 additions & 5 deletions Manager/TFSBuildManager.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace TFSBuildManager.Console
using System.Text.RegularExpressions;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
using TfsBuildManager.Views;
using TfsBuildManager.Views;
using System.Net;

public class Program
{
Expand Down Expand Up @@ -101,8 +102,35 @@ internal static string ExportPath

throw new ArgumentNullException("ExportPath");
}
}

internal static string Username
{
get
{
string username;
if (Arguments.TryGetValue("Username", out username))
{
return username;
}

throw new ArgumentNullException("Username");
}
}

internal static string Password
{
get
{
string password;
if (Arguments.TryGetValue("Password", out password))
{
return password;
}

throw new ArgumentNullException("Password");
}
}

private static int Main(string[] args)
{
Console.WriteLine("Community TFS Build Manager Console - {0}\n", GetFileVersion(Assembly.GetExecutingAssembly()));
Expand All @@ -116,9 +144,16 @@ private static int Main(string[] args)
if (retval != 0)
{
return retval;
}

TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(ProjectCollection);
}

NetworkCredential netCred = new NetworkCredential(Username, Password);
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(ProjectCollection, tfsCred);

collection.Authenticate();

IBuildServer buildServer = (IBuildServer)collection.GetService(typeof(IBuildServer));

Expand Down Expand Up @@ -221,6 +256,20 @@ private static int ProcessArguments(string[] args)
if (propertiesargumentfound)
{
Arguments.Add("ExportPath", args.First(item => item.Contains("/ExportPath:")).Replace("/ExportPath:", string.Empty));
}

searchTerm = new Regex(@"/Username:.*");
propertiesargumentfound = args.Select(arg => searchTerm.Match(arg)).Any(m => m.Success);
if (propertiesargumentfound)
{
Arguments.Add("Username", args.First(item => item.Contains("/Username:")).Replace("/Username:", string.Empty));
}

searchTerm = new Regex(@"/Password:.*");
propertiesargumentfound = args.Select(arg => searchTerm.Match(arg)).Any(m => m.Success);
if (propertiesargumentfound)
{
Arguments.Add("Password", args.First(item => item.Contains("/Password:")).Replace("/Password:", string.Empty));
}

Console.Write("...Success\n");
Expand Down