有没有办法根据TFS 2012中的文件扩展名禁用签入权限?

时间:2016-02-08 15:43:16

标签: tfs tfs2012

我需要允许设计师只使用 .aspx, .css,*。html ....等,并禁用他对* .cs文件的许可。

在TFS 2012中有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

您为此撰写了自定义checkin policy

// This method performs the actual policy evaluation. 
// It is called by the policy framework at various points in time
// when policy should be evaluated. In this example, the method 
// is invoked when various asyc events occur that may have 
// invalidated the current list of failures.
public override PolicyFailure[] Evaluate()
{
    string proposedComment = PendingCheckin.PendingChanges.Comment;
    if (PendingCheckin.PendingChanges.Any(x => x.Filename.EndsWith(".cs")) && CurrentUser.CanNotEditCodeFiles)
    {
        return new PolicyFailure[] {
            new PolicyFailure("You are not authorized to edit *.cs files.", this) };
    }
    else
    {
        return new PolicyFailure[0];
    }
}

此代码无法编译,因为我在其中添加了一些伪代码作为示例,但此方法应涵盖您的用例。