如何获得新的TeamFoundation 2013模板Workspace对象 [英] How to get Workspace object in new TeamFoundation 2013 Templates
问题描述
在TeamFoundation 2013默认建立模板新版本中,工作
变量缺失。这是需要作为intput参数如 ConvertWorkspaceItem
几个关键活动。我如何获得当前工作区TfvcTemplate.12.xaml模板?我试图使用的这个MSDN线程但它不是为我工作(返回null工作区名称)。有什么建议?
In new version of TeamFoundation 2013 default build templates, the Workspace
variable is missing. It is needed as intput parameter for few key activities like ConvertWorkspaceItem
. How do I get current workspace for TfvcTemplate.12.xaml templates? I've tried to use this msdn thread but it's not working for me (returns null workspace name). Any suggestions?
推荐答案
我用内部类,从一劈去 Microsoft.TeamFoundation.Build.Activities .DLL
(使用微软创建工作区名称)。您需要创建自定义活动与下面的代码:
I went with a hack using internal classes from Microsoft.TeamFoundation.Build.Activities.dll
(used by microsoft to create workspace name). You need to create custom activity with following code:
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;
}
}
这篇关于如何获得新的TeamFoundation 2013模板Workspace对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!