运行 在 Visual Studio 团队服务构建期间以管理员身份使用 Powershell 或命令提示符
Run Powershell or Command Prompt as administrator during Visual Studio Team Services build
我正在处理一个我们延迟签署程序集的项目。我需要在构建过程中多次使用强名称工具,关闭强名称验证,然后在打包之前对程序集进行完全签名。我试图使用 powershell 步骤来关闭验证,但返回此错误:
脚本:
$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 参数。这没有什么区别。
我还尝试使用命令提示符步骤而不是 powershell。这也返回了同样的错误。
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.
我假设您正在使用自己的构建代理进行构建。那么这可能是由于构建代理不是 运行 管理员帐户造成的。请使用管理员帐户将您的构建代理更新为 运行,然后重试。
Run the agent Run as a service
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:\Agent\Agent\VsoAgent.exe /ChangeWindowsServiceAccount Run
interactively
Otherwise if you installed the agent to run interactively, the agent
can be started by launching Agent\VsoAgent.exe.
参考这个link了解详情:Run the agent
我正在处理一个我们延迟签署程序集的项目。我需要在构建过程中多次使用强名称工具,关闭强名称验证,然后在打包之前对程序集进行完全签名。我试图使用 powershell 步骤来关闭验证,但返回此错误:
脚本:
$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 参数。这没有什么区别。
我还尝试使用命令提示符步骤而不是 powershell。这也返回了同样的错误。
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.
我假设您正在使用自己的构建代理进行构建。那么这可能是由于构建代理不是 运行 管理员帐户造成的。请使用管理员帐户将您的构建代理更新为 运行,然后重试。
Run the agent Run as a service
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:\Agent\Agent\VsoAgent.exe /ChangeWindowsServiceAccount Run
interactivelyOtherwise if you installed the agent to run interactively, the agent can be started by launching Agent\VsoAgent.exe.
参考这个link了解详情:Run the agent