开发者

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. 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).a开发者_JS百科spx but I cannot figure out how to use the credentials within the XAML file.

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)?

Thanks, Stephanie


I have solved my issue here. I wasn't aware that the activities were coded in C#, although organized through the XML.


You can use a TryCatch activity to wrap the impersonation object and dispose it in the Finally.

The XAML should look like:

            <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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜