简体   繁体   中英

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).aspx 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>

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