开发者

Deleting app_offline during TFS 2010 build

I have a custom TFS Build process for my Web Application Project, which also does a publish. To accomplish this I attempt to delete the current publish location before copying over the compiled sources from the build.

This works (most of the time) except when f开发者_Python百科iles are locked because there are people accessing the site, generally not a problem since most of the time the builds happen when no-one is access them (as these are purely development and QA builds).

To try and fix those edge cases where the publish directory can't be deleted, I copy an app_offline.htm file to the directory and wait 4 seconds before trying to delete the rest of the site. This works and I haven't gotten any errors from this step however, when I try to delete the app_offline.htm after the publish is finished. I get the following error:

Cannot cancel the workflow. Agent needs to be restarted. Details: The operation could not be performed because WorkflowApplication f670d4fb-d9e3-4f33-bc3d-925faa925e04 is aborted.

The delete is created using a custom CodeActivity (since TFS Workflow doesn't have a delete).

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));
            }
        }
    }
}

I added the "Tries" argument later to try and catch what was causing this error.

However, of note, when viewing the log, the error above is not placed under the DeleteFile activity, but only at the top of the log and there are no other errors or warnings.

Lastly, our tfsbuild user has delete permissions on the publish directory (it has no issues deleting the rest of the directory just app_offline.htm


I've seen this error before and were told that it typically means an unhandled exception was thrown from an asynchronous thread or while evaluating a lambda exception to retrieve an argument/variable value in the workflow. You can either hop on the build machine or try debugging the build service host remotely to catch the unhandled exception (which probably is thrown from one of your custom activities that you introduced recently).

Hope this helps.


Had this same problem happen today and discovered a newly installed virus protection app on the build server had quarantined psexec.exe. The TFS build template was configured to encrypt the connection string section and it uses psexec to do this. The build log had Access Denied error at the end and app_offline.htm had not been deleted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜