如何实现 TFS InvokeProcess 在其他凭据下运行

发布于 2024-11-17 10:01:33 字数 641 浏览 1 评论 0原文

我正在使用 TFS (VS 2010) 构建定义和 XAML 来构建适用于不同环境的应用程序。现在,我们需要将这些构建推送到生产服务器,这些服务器需要与构建控制器不同的凭据。

我一直致力于实施“自定义 Team Build 2010 – 第 9 部分:模拟活动(在其他凭据下运行)”(来自 http://www.ewaldhofman.nl/post/2010/05/28/Customize-Team-Build-2010-e28093-Part-9-Impersonate-activities-(run-under-other-credentials ).aspx 但我无法弄清楚如何在 XAML 文件中使用凭据。

因此,我已经实现了提供的解决方案,并且使构建定义需要凭据,但是如何将凭据代码(似乎是 C# 中的)实现到 XAML(是 XML 中)?

谢谢, 斯蒂芬妮

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪推晚风 2024-11-24 10:01:33

我已经在这里解决了我的问题。我不知道这些活动是用 C# 编码的,尽管它们是通过 XML 组织的。

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

虐人心 2024-11-24 10:01:33

您可以使用 TryCatch 活动来包装模拟对象并将其放置在 Final 中。

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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文