[英]How to Implement TFS InvokeProcess to run under other credentials
I'm using TFS (VS 2010) Build Definitions and XAMLs to build apps to different environments. 我正在使用TFS(VS 2010)生成定义和XAML来将应用程序生成到不同的环境。 Now, we need to push these builds to Production servers which require different credentials than what the Build Controller has. 现在,我们需要将这些构建推送到生产服务器,这些服务器所需的凭据与构建控制器所需的凭据不同。
I have been working on implementing the steps found at " Customize Team Build 2010 – Part 9: Impersonate activities (run under other credentials) " from http://www.ewaldhofman.nl/post/2010/05/28/Customize-Team-Build-2010-e28093-Part-9-Impersonate-activities-(run-under-other-credentials).aspx but I cannot figure out how to use the credentials within the XAML file. 我一直在努力执行http://www.ewaldhofman.nl/post/2010/05/28/Customize-Team的 “ 自定义团队构建2010 –第9部分:模拟活动(在其他凭据下运行) ”中的步骤。 -Build-2010-e28093-Part-9-模拟活动((在其他凭据下运行).aspx),但我无法弄清楚如何在XAML文件中使用凭据。
So, I have implemented the provided solution, and have made build definitions require the credentials, but how do I implement the credentials code (which appears to be in C#) into the XAML (which is XML)? 因此,我已经实现了所提供的解决方案,并已使构建定义要求凭据,但是如何将凭据代码(似乎在C#中)实现到XAML(XML)中呢?
Thanks, Stephanie 谢谢斯蒂芬妮
I have solved my issue here. 我已经在这里解决了我的问题。 I wasn't aware that the activities were coded in C#, although organized through the XML. 我不知道这些活动是用C#编码的,尽管是通过XML进行组织的。
You can use a TryCatch activity to wrap the impersonation object and dispose it in the Finally. 您可以使用TryCatch活动包装模拟对象并将其放置在Final中。
The XAML should look like: XAML应该看起来像:
<TryCatch>
<TryCatch.Variables>
<Variable x:TypeArguments="bl:Impersonation" Name="Impersonation" />
</TryCatch.Variables>
<TryCatch.Try>
<Sequence>
<mtbwa:WriteBuildMessage Message="Impersonating..." />
<ba:CreateImpersonationContext Credentials="[Credentials]" Result="[Impersonation]" />
<!-- Your activities go here -->
</Sequence>
</TryCatch.Try>
<TryCatch.Finally>
<Sequence>
<ba:DisposeImpersonationContext Impersonation="[Impersonation]" />
<mtbwa:WriteBuildMessage Message="Done with impersonation!" />
</Sequence>
</TryCatch.Finally>
</TryCatch>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.