在 Visual Studio Team Services 构建期间以管理员身份运行 Powershell 或命令提示符 [英] Run Powershell or Command Prompt as administrator during Visual Studio Team Services build

查看:28
本文介绍了在 Visual Studio Team Services 构建期间以管理员身份运行 Powershell 或命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个我们延迟签署程序集的项目.我需要在构建过程中多次使用强名称工具,关闭强名称验证,然后在程序集打包之前对其进行完全签名.我尝试使用 powershell 步骤关闭验证,但它返回此错误:

I am working on a project where we are delay signing the assemblies. I need to use the strong name tool a couple times during the build, to turn off strong name verification, and then to fully sign the assemblies before they are packaged. I attempted to use a powershell step to turn off verification, but it came back with this error:

脚本:

$testprojs = gci Project.*.dll -r
$testprojs | % {
            sn -Vr $_
            write-output $("Turned off sn verification for " + $_.Name)
}

错误:

Failed to open registry key -- Administrator permissions are needed to use
the selected options. Use an administrator command prompt to complete these tasks.

所以我创建了一个脚本来运行第一个脚本,但添加了 -elevated 参数.这没什么区别.

So I created a script that would run the first one, but added the -elevated parameter. This made no difference.

我还尝试使用命令提示符步骤而不是 powershell.这也返回了同样的错误.

I also tried using a command prompt step instead of powershell. This also returned the same error.

For /r %g in ("Project.*.dll") DO sn -Vr %g

当我尝试对构建代理机器本身运行这个相同的脚本 rdp 时,它按预期工作.只有当它作为构建中的一个步骤运行时才不起作用.

When I tried running this same script rdp'd to the build agent machine itself, it works as intended. It's only when it runs as a step in the build does it not work.

有什么想法吗?

推荐答案

根据你的描述:

当我尝试在构建代理机器上运行相同的脚本时本身,它按预期工作.

When I tried running this same script rdp'd to the build agent machine itself, it works as intended.

我假设您使用自己的构建代理进行构建.那么这可能是由于构建代理未使用管理员帐户运行造成的.请更新您的构建代理以使用管理员帐户运行,然后重试.

I assume you are using your own build agent for build. Then this may caused by the build agent isn't running with an administrator account. Please update your build agent to run with administrator account and then try again.

运行代理作为服务运行

如果您将代理部署为作为 Windows 服务运行,则代理可以从服务管理单元控制运行状态.跑services.msc 并查找VSO 代理 ()".如果你需要更改登录帐户,不要从服务中进行管理单元.相反,从提升的命令提示符运行:C:AgentAgentVsoAgent.exe/ChangeWindowsServiceAccount 运行交互

If you deployed the agent to run as a Windows service, then the agent running status can be controlled from the Services snap-in. Run services.msc and look for "VSO Agent ()". If you need to change the logon account, don't do it from the services snap-in. Instead, From an elevated Command Prompt, run: C:AgentAgentVsoAgent.exe /ChangeWindowsServiceAccount Run interactively

否则,如果您安装了以交互方式运行的代理,则代理可以通过启动 AgentVsoAgent.exe 来启动.

Otherwise if you installed the agent to run interactively, the agent can be started by launching AgentVsoAgent.exe.

详情请参考此链接:运行代理

这篇关于在 Visual Studio Team Services 构建期间以管理员身份运行 Powershell 或命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆