【发布时间】:2014-03-31 19:40:33
【问题描述】:
我开发了一个 powershell 脚本,它接受一个 bundlea 参数、创建一个 MSDeploy 字符串并执行它。我已经测试了这个 powershell 命令:
- 它适用于我的本地盒子(从我的本地盒子安装 Web 应用程序到 远程 IIS 服务器)
- 它适用于 TeamCity 盒子(安装 web 应用程序从团队城市的文件夹结构到远程 iis 服务器)
问题:
当我从 teamcity 的浏览器版本运行命令时它不起作用。
错误是:ERROR_USER_NOT_ADMIN
请注意,我的 Teamcity Build Agent 是我的 teamcity 服务器和 IIS 远程服务器上的本地管理员
Powreshell 源代码:
$msDeploy = 'C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe'
$sourcePackage = $args[0]
$paramFile = $args[1]
$iisAppPath = $args[2]
$servername = $args[3]
$usreName = $args[4]
$password = $args[5]
$includeAcls = $args[6]
function UpdateParamFile($paramXMLFile, $applicationPath)
{
$doc = New-Object System.Xml.XmlDocument
$doc.Load($paramXMLFile)
#IIS Application Path (this is where the code will be deployed - it has to exist in target IIS):
$appPath = $doc.SelectSingleNode("//parameters//setParameter[@name = 'IIS Web Application Name']")
$appPath.value = $applicationPath
#Connection Strings:
#KDB Connection string:
#Save
$doc.Save($paramXMLFile)
#[xml] $xmlPars = Get-Content $paramXMLFile
#$xmlPars.parameters.setParameter | Where-Object { $_.name -eq 'IIS Web Application Name' } | select value
}
UpdateParamFile $paramFile $iisAppPath
$arguments = "-source:package=$sourcePackage", "-dest:auto,computerName=`"$servername`",userName=`"$usreName`",password=`"$password`",includeAcls=`"$includeAcls`"", "-setParamFile:$paramFile", '-verb:sync', '-disableLink:AppPoolExtension', '-disableLink:CertificateExtension', '-disableLink:ContentExtension'
&$msDeploy $arguments
Teamcity 调用上述脚本文件:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy ByPass -文件 C:\TeamCity\buildAgent\work\253e6183c0596123\Debug\PMRSWebsite\DeployWeb.ps1 Debug\PMRSWebsite\Web。 csproj.zip "Debug\PMRSWebsite\Web.csproj.SetParameters.xml" ^^^IIS_APP_NAME^^^ ^^^ServerName^^^ ^^^userName^^^ ^^^Password^^^ false
【问题讨论】:
标签: powershell msbuild teamcity msdeploy