【问题标题】:MSdeploy in Powershell - show or help me something really workingPowershell 中的 MSdeploy - 向我展示或帮助我一些真正有效的东西
【发布时间】: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


【解决方案1】:

这是一个使用参数启动 notepad.exe 的小示例

function F([string]$file)
 { 
    notepad.exe $file
 } 

 Clear-Host
 F "c:\Temp\fic.txt"

日本

【讨论】:

    【解决方案2】:

    试试这个要点。它应该拥有您通过 powershell https://gist.github.com/579086 部署所需的一切@

    它使用 Psake,但没有它也可以工作。

    【讨论】:

    • $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)
    • 现在,我可以将所需的一切保存到 $runMSDeploy。那么我可以使用什么其他命令来运行这个带有其余参数的 msdeploy.exe?
    猜你喜欢
    • 1970-01-01
    • 2019-05-27
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多