English 中文(简体)
在TFS 2010生成期间删除app_offline
原标题:Deleting app_offline during TFS 2010 build

我的Web应用程序项目有一个自定义的TFS构建过程,该过程还进行发布。为了实现这一点,我尝试在从构建复制已编译的源之前删除当前发布位置。

这是有效的(大多数时候),除非文件被锁定,因为有人访问网站,这通常不是问题,因为大多数时候构建都是在没有人访问的情况下发生的(因为这些纯粹是开发和QA构建)。

为了尝试修复那些无法删除发布目录的边缘情况,我将app_offline.htm文件复制到该目录中,等待4秒钟后再尝试删除网站的其余部分。这是有效的,但是,当我尝试在发布完成后删除app_offline.htm时,我没有从这一步中得到任何错误。我得到以下错误:

无法取消工作流。需要重新启动代理。详细信息:无法执行该操作,因为WorkflowApplication f670d4fb-d9e3-4f33-bc3d-925faa925e04已中止。

删除是使用自定义CodeActivity创建的(因为TFS工作流没有删除)。

public sealed class DeleteFile : CodeActivity
{
    // Define an activity input argument of type string
    [RequiredArgument]
    public InArgument<string> File { get; set; }
    public InArgument<int?> Tries { get; set; }

    // If your activity returns a value, derive from CodeActivity<TResult>
    // and return the value from the Execute method.
    protected override void Execute(CodeActivityContext context)
    {
        // Obtain the runtime value of the Text input argument
        int tries = Tries.Get(context) ?? 1;
        for (int i = 0; i < tries; i++)
        {
            try
            {
                System.IO.File.Delete(File.Get(context));
                break;
            }
            catch (System.IO.IOException)
            {
                if (i == tries - 1)
                    throw;
                Thread.Sleep(TimeSpan.FromSeconds(4));
            }
        }
    }
}

我后来添加了“Tries”参数,试图找出导致此错误的原因。

但是,值得注意的是,在查看日志时,上面的错误不会放在DeleteFile活动下,而是只放在日志的顶部,并且没有其他错误或警告。

最后,我们的tfsbuild用户对发布目录具有删除权限(删除目录的其余部分没有问题,只删除app_offline.htm

问题回答

我以前见过这个错误,并被告知这通常意味着从异步线程或在评估lambda异常以检索工作流中的参数/变量值时抛出了未处理的异常。您可以跳上生成计算机,也可以尝试远程调试生成服务主机,以捕获未处理的异常(可能是您最近引入的某个自定义活动引发的异常)。

希望这能有所帮助。

今天也发生了同样的问题,发现生成服务器上新安装的病毒防护应用程序已隔离psexec.exe。TFS生成模板已配置为加密连接字符串部分,并使用psexec执行此操作。生成日志末尾出现“拒绝访问”错误,app_offline.htm尚未删除。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签