我在Visual Studio 2010中爲TFS 2010創建自定義簽入策略。策略本身運作良好。現在,我正嘗試從代碼應用自定義策略。下面是我的代碼:如何在visual studio 2010中爲自定義簽入策略創建PolicyEnvelope?
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
您的政策是否實施「IPolicyDefenition」? – DaveShaw 2013-02-19 20:06:43
是的,它的確如此...... – PushCode 2013-02-19 20:09:11