C# 使用Powershell绕过TFS门控签入

C# 使用Powershell绕过TFS门控签入,c#,powershell,C#,Powershell,我正在研究一个进程,该进程涉及将一些数据文件检入到具有门控检入进程的构建中。在Powershell中,我将代码放在一起,如下所示: $pendings = $ws.GetPendingChanges() if($pendings.Count -gt 0) { $ws.CheckIn($pendings, $checkInComments); } 如果该代码位于手动值机区,我添加了所有DLL等等,那么它的功能将非常完美。但是,如果构建是封闭的,它将失败,原因是: Exception ca

我正在研究一个进程,该进程涉及将一些数据文件检入到具有门控检入进程的构建中。在Powershell中,我将代码放在一起,如下所示:

$pendings = $ws.GetPendingChanges()
if($pendings.Count -gt 0)
{
    $ws.CheckIn($pendings, $checkInComments);
}
如果该代码位于手动值机区,我添加了所有DLL等等,那么它的功能将非常完美。但是,如果构建是封闭的,它将失败,原因是:

Exception calling "CheckIn" with "2" argument(s): 
"Your check-in could not be completed because it affects the following gated build definitions.
我在C中找到了这个问题的以下答案,但我似乎无法将其转换为Powershell,据我所知,如果我添加了相应的DLL,.net方法应该对我可用

var pendingChanges = workspace.GetPendingChanges();
if (pendingChanges.Any())
{
    WorkspaceCheckInParameters parameters = new WorkspaceCheckInParameters(pendingChanges, BuildCommonUtil.NoCICheckInComment)
    {
        OverrideGatedCheckIn = true,
    };
    workspace.CheckIn(parameters);
}
有人知道我如何绕过Powershell中假定的封闭权限吗?

您可以在设置封闭签入工作区时尝试使用此选项

Microsoft.TeamFoundation.VersionControl.ClientCheckInParameters.OverrideGatedCheckIn属性
请参阅:

我在互联网上查看了所有powershell文档、MSDN参考,找到了与powershell的OverrideGatedCheckIn=true等效的代码,我找到的所有代码都在非工作代码下面

Write-Host "tf.exe checkin"
        & $tfexe checkin $wsp /comment:"***NO_CI***" 
        /bypass /noprompt /recursive /override:"Auto-Build: Version Update" | Out-Null
解决方案

因此,我对此问题的解决方案是将程序集版本控制文件AssemblyInfo.vb和AssemblyInfo.cs移动到名为SharedAssembly的文件夹中,并将其排除在GatedCheck进程之外