Powershell 中的 MSdeploy - 展示或帮助我一些真正有效的东西

发布于 2024-10-25 20:30:48 字数 1130 浏览 5 评论 0原文

我在工作中设置了 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;
'-如果> c:\temp\msdeploy.log'
)


$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy | $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 文件夹]] -dest:contentPath=[[目标 UNC 路径]] -如果> c:\temp\msdeploy.log

这是我现在陷入困境的地方。由于 c:\Program 文件包含空文件夹,cmd 无法成功运行,而是给出错误,“cmd.exe : 'C:\Program' 未被识别为内部或外部命令”

如果您有任何建议或想法,请告诉我。

谢谢,

每天都想粉碎

I set up TFS Deployer currenlty at work and have been tried to write a Powershell script for the deployment. I have been researched and read many posted questions and answers at StackoverFlow but I couldn't really making the script working yet.

So far, when I run the following PS on windows PowerShell ISE, it runs.

$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy

# defined the current location to $DirMSDeploy = 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 | Out-file c:\temp\MsDeployTest.bat

I put the last sentence to confirm what gets saved $runMSDeploy. Now looks like $runMSDeploy saves what I want to put finally.

MSDeployTest.Bat contains C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC path]] -whatif > c:\temp\msdeploy.log

This is where I'm stuck at right now. Because of the c:\Program files contains the empty folder, cmd doesn't run successfully rather giving me the error, "cmd.exe : 'C:\Program' is not recognized as an internal or external command"

If you have any suggestions or idea, please let me know.

thanks,

wanttogoshreddingeveryday

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骷髅 2024-11-01 20:30:48

启动 notepad.exe 的小示例

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

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

这是一个使用参数JP

Here is a small example which start notepad.exe with a parametter

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

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

JP

以酷 2024-11-01 20:30:48

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

它使用不过,没有它也能工作。

Try this gist. It should have everything you need to deploy via powershell https://gist.github.com/579086

It uses Psake, but it will work without it as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文