我在 Visual Studio 2010 中为 TFS 2010 创建了一个自定义签入策略。该策略本身运行良好。现在,我正在尝试从代码中应用自定义策略。下面是我的代码:
try
{
var projectCollectionUri = new Uri("https://mydomain.com/tfs");
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, new UICredentialsProvider());
projectCollection.EnsureAuthenticated();
var vcs = projectCollection.GetService<VersionControlServer>();
var teamProject = vcs.GetTeamProject("myProject");
foreach (PolicyType policyType in Workstation.Current.InstalledPolicyTypes)
{
if (policyType.Name.ToLower().Contains("MyPolicyType"))
{
//teamProject.SetCheckinPolicies(new PolicyEnvelope[] { new PolicyEnvelope(workItemPolicy, policyType) });
//break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
我被困在这条线上:
//teamProject.SetCheckinPolicies(new PolicyEnvelope[] { new PolicyEnvelope(workItemPolicy, policyType) });
如何为我的自定义策略创建策略信封?我引用的代码来自以下位置: http ://bartwullems.blogspot.com/2012/02/team-foundation-server-2010-enable.html