private static IVssDeploymentServiceHost CreateDeploymentServiceHost(string configDbConnectionString) { TeamFoundationServiceHostProperties deploymentHostProperties = new TeamFoundationServiceHostProperties(); deploymentHostProperties.HostType = TeamFoundationHostType.Deployment | TeamFoundationHostType.Application; deploymentHostProperties.PlugInDirectory = Path.Combine(GetTfsInstallationDir(), @"Application Tier\TFSJobAgent\Plugins"); return(Microsoft.TeamFoundation.Framework.Server.DeploymentServiceHostFactory.CreateDeploymentServiceHost(deploymentHostProperties, SqlConnectionInfoFactory.Create(configDbConnectionString, null, null))); }
private TeamFoundationJobService GetJobService() { TeamFoundationServiceHostProperties deploymentHostProperties = new TeamFoundationServiceHostProperties(); deploymentHostProperties.HostType = TeamFoundationHostType.Deployment | TeamFoundationHostType.Application; deploymentHostProperties.Id = Guid.Empty; deploymentHostProperties.PlugInDirectory = Path.Combine(tfsInstallPath, TFS_JOB_EXTENSIONS_PATH); deploymentHostProperties.PhysicalDirectory = string.Empty; deploymentHostProperties.VirtualDirectory = string.Empty; DeploymentServiceHost host = null; ISqlConnectionInfo connInfo = SqlConnectionInfoFactory.Create(connectionString, null, null); deploymentHostProperties.ConnectionInfo = connInfo; host = new DeploymentServiceHost(deploymentHostProperties, true); if (collectionContext != null) { collectionContext.Dispose(); collectionContext = null; } if (deploymentContext != null) { deploymentContext.Dispose(); } deploymentContext = host.CreateSystemContext(); if (rbServer.Checked) { currentContext = deploymentContext; return(deploymentContext.GetService <TeamFoundationJobService>()); } else { var hms = deploymentContext.GetService <TeamFoundationHostManagementService>(); collectionContext = hms.BeginRequest(deploymentContext, tpc.InstanceId, RequestContextType.SystemContext); currentContext = collectionContext; return(collectionContext.GetService <TeamFoundationJobService>()); } }