【发布时间】:2011-07-21 18:46:17
【问题描述】:
我在工作中设置了 TFS Deployer,并尝试为部署编写 Powershell 脚本。我已经在 StackoverFlow 上研究并阅读了许多发布的问题和答案,但我还不能真正使脚本正常工作。
到目前为止,当我在 Windows PowerShell ISE 上运行以下 PS 时,它会运行。
$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy
# 将当前位置定义为 $DirMSDeploy = C:\Program Files\IIS\Microsoft Web Deploy V2
设置位置 $DirMsDeploy
$arg = @(
'-动词:同步';
'-source:contentPath=' + $buildDroppedLocation;
'-dest:contentPath=' + $destinationPath;
' -whatif > c:\temp\msdeploy.log'
)
$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy |输出文件 c:\temp\MsDeployTest.bat
我放了最后一句来确认 $runMSDeploy 保存了什么。现在看起来 $runMSDeploy 最终保存了我想要放置的内容。
MSDeployTest.Bat 包含 C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC路径]] -whatif > c:\temp\msdeploy.log
这就是我现在所困的地方。由于 c:\Program 文件包含空文件夹,cmd 无法成功运行,而是给我错误,“cmd.exe : 'C:\Program' 不被识别为内部或外部命令”
如果您有任何建议或想法,请告诉我。
谢谢,
每天都想切碎
【问题讨论】:
-
$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy # 定义当前位置为 C:\Program Files\IIS\Microsoft Web Deploy V2 set-location $DirMsDeploy $arg = @( '-verb:sync'; '-source:contentPath=' + $buildDroppedLocation; '-dest:contentPath=' + $destinationPath; ' -whatif > c:\temp\msdeploy.log' ) $runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg) -
#BEGIN $MsDeployDir = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MSDeploy)。'(默认)' $MsDeployExe = $MsDeployDir |加入路径 -ChildPath msdeploy.exe & cmd.exe /c $('" "{0}" -verb:sync -source:contentPath="{1}" -dest:contentPath="{2}" -whatif " ' -f $MSDeployExe, $BuildDroppedLocation, $DestinationPath) #END
-
开发 TFS Deployer 的 Jason Stangroome 在这里帮助了我 tfsdeployer.codeplex.com/discussions/251531
标签: iis-7 powershell msdeploy