简体   繁体   中英

TFS custom activity is reporting the TFS workspace is deleted

I have a custom TFS activity that returns the current workspace. The code I am using was found in this post, and is reproduced here...

https://stackoverflow.com/a/21045346/131270

public sealed class GetDefaultWorkspace : BaseActivity<Workspace>
{     
    public override Activity CreateBody()
    {
        var type = typeof(TfGetSources).Assembly.GetType("Microsoft.TeamFoundation.Build.Activities.TeamFoundation.TfGetSources+GetDefaultWorkspaceName");

        var activity = (CodeActivity<string>)Activator.CreateInstance(type);
        var sequence = new Sequence();
        var workspaceName = new Variable<string>();

        sequence.Variables.Add(workspaceName);
        sequence.Activities.Add(activity);
        activity.Result = (OutArgument<string>) workspaceName;

        sequence.Activities.Add(new GetWorkspace
            {
                Name = workspaceName,
                Result = new LambdaReference<Workspace>(ctx => Result.Get(ctx))
            });

        return sequence;
    }
}

I return the value of this into a Workspace typed variable, and then pass that into another custom TFS activity that needs the workspace to check an item in.

I unwrap the workspace using...

    public InArgument<Workspace> Workspace { get; set; }

    // If your activity returns a value, derive from CodeActivity<TResult>
    // and return the value from the Execute method.
    protected override void Execute()
    {
        var workspace = _context.GetValue<Workspace>(Workspace);

The returned workspace exists, but it is reported as deleted...

Exception Message: The workspace 10_1_RQ-SRV-TFS-12r2;NETWORK SERVICE has been deleted. (type WorkspaceDeletedException) Exception Stack Trace: at Microsoft.TeamFoundation.VersionControl.Client.Workspace.PendEdit(String path) at RQTfsActivities.RQSetVersion.Execute() 

The log file shows the passed in workspace as...

Inputs 
    Workspace: 10_1_RQ-SRV-TFS-12r2;NT AUTHORITY\NETWORK SERVICE 

How do I resolve this?

When the GetDefaultWorkspace activity was placed after the Initialize Environment activity but before the Get Sources activity, it showed deleted. I moved GetDefaultWorkspace to after the Get Sources activity and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM