MSDeploy安装Windows服务?

发布于 2024-09-30 12:16:27 字数 232 浏览 2 评论 0 原文

我们有一个使用 NServiceBus 发布事件的网站。该站点是使用 msdeploy 部署的。我们还有 NServiceBus.exe,它应该作为 Windows 服务运行来订阅这些事件,我们也想部署它。

有什么办法可以将服务和网站打包在一起,以便也可以安装吗?是否可以单独打包以便我们可以将其部署到另一台服务器上?

关于在哪里可以找到有关如何执行此操作的信息的任何提示都很棒,因为我们现在可以为网站进行自动化部署。

We have a website which publishes events using NServiceBus. The site is deployed using msdeploy. We also have the NServiceBus.exe which should run as a windows service to subscribe to these events, and we'd like to deploy that as well.

Is there any way to package the service as well as the website, so that it can be installed as well? Is it possible to package separately so we can deploy it to another server?

Any tips on where to find information on how to do this would be great, as we can do automated deployments for the website now.

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

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

发布评论

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

评论(3

浊酒尽余欢 2024-10-07 12:16:27

我最近使用 MSDeploy、Phantom 和 installUtil.exe 完成了此操作。

您基本上只需要修改安装程序类并在需要时提升远程 wmsvc 服务权限。

博客链接

I recently did this using MSDeploy, Phantom and installUtil.exe

You just basically need to modify your installer class and elevate your remote wmsvc service privileges if needed.

Link to blog

无需解释 2024-10-07 12:16:27

我们最终要做的是创建一个“控制器”层来协调部署任务,甚至可以使用 msdeploy。本质上,msdeploy 并不是我们部署系统中的最高抽象级别。

我们选择使用 MSBuild 来协调从“包”部署项目的任务。

在我们的部署过程中,使用msdeploy部署的Web应用程序只是另一个部署项,就像Windows服务一样。

总而言之,我们实际上还没有创建 msdeploy 部署任务,尽管它应该/会很好地融入到我们已经创建的任务中,因为 MSBuild 会调用 msdeploy。目前,我们使用 MSBuild 社区任务来实现 Web 应用程序部署自动化,并通过 MSBuild 进行协调。

您可以通过我写的一篇名为“PANDA - 打包和部署自动化”。

What we wound up doing was creating a 'controller' layer that coordinates deployment tasks, even one that could use msdeploy. Essentially, msdeploy is not the highest level of abstraction in our deployment system.

We chose to use MSBuild to coordinate those tasks of deploying items from a 'package'.

In our deployment process, a web application deployed with msdeploy is just another deployment item, just as is a Windows service.

In all disclosure, we have not actually created msdeploy deployment tasks yet, though it should/would drop in nicely to what we've already created, as MSBuild would invoke the msdeploy. We currently use MSBuild community tasks for webapp deployment automation, coordinated via MSBuild.

You can read a little more about how we 'generalized' our deployments via a blog post I did called "PANDA - Packaging ANd Deployment Automation".

姐不稀罕 2024-10-07 12:16:27

下面是我用来同步从 Windows Service.proj 文件中的构建后步骤创建的 archivedir 的 msdeploy 命令行。

它正在从我的构建服务器同步到不同网络上的应用程序服务器。我有启动和停止远程服务器上的服务的构建前和构建后步骤。由于 powershell 和 msdeploy 存在错误,您必须将 powershell 脚本包装在 vb 脚本中。 -verbose 选项非常有用。

我还有下面的 vbscript 和 ps1 脚本。请注意 VB 睡眠以及 msdeploy 前后的超时。

msdeploy -verb:sync -source:archivedir=\\qa-xxxxx1.qa.lan\deployment\backups\FreddieMacDelivery\FreddieMacDelivery.zip,tempAgent='True',computerName=qa-xxxxx1.qa.lan,userName=QA\xxxxx,password=xxxx,authtype=NTLM,includeAcls='False' -dest:dirpath=\\qa-xxxxxx1.qa.lan\protk\Services\FreddieMacDelivery\1.4.1.test -useCheckSum -verbose -preSync:runCommand="cscript.exe c:\temp\stop_win_svc.vbs" -postSync:runCommand="c:\temp\start_win_svc.vbs",waitInterval=15000,waitAttempts=1

VB 脚本:

Option Explicit
Dim oShell, appCmd,oShellExec
Set oShell = CreateObject("WScript.Shell")

appCmd = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ""&c:/temp/Get_Win_SVC.ps1"" "

Set oShellExec = oShell.Exec(appCmd)

WScript.Sleep 1000
oShellExec.StdIn.Close()

Powershell 脚本:

$username = 'QA\xxxxx'
$password = 'xxxxx'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

(Get-WmiObject  -computer qa-xxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")


$svc = (Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'") 

Write-Host  $svc

$svc.InvokeMethod("StartService", $null)


(Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")> c:\temp\win_stat_post.txt

Here is a msdeploy cmd line I used to sync an archivedir that is created from a post-build step in my Windows Service.proj file.

It is syncing from my build server to my app server on a different network. I have pre and post build steps that start and stop the services on the remote server. You must wrap the powershell script in a vb script due to a bug with powershell and msdeploy. The -verbose option is very helpful.

I also have the vbscript and ps1 script below. Be careful with the VB sleep and the pre and post msdeploy timeouts.

msdeploy -verb:sync -source:archivedir=\\qa-xxxxx1.qa.lan\deployment\backups\FreddieMacDelivery\FreddieMacDelivery.zip,tempAgent='True',computerName=qa-xxxxx1.qa.lan,userName=QA\xxxxx,password=xxxx,authtype=NTLM,includeAcls='False' -dest:dirpath=\\qa-xxxxxx1.qa.lan\protk\Services\FreddieMacDelivery\1.4.1.test -useCheckSum -verbose -preSync:runCommand="cscript.exe c:\temp\stop_win_svc.vbs" -postSync:runCommand="c:\temp\start_win_svc.vbs",waitInterval=15000,waitAttempts=1

VB script:

Option Explicit
Dim oShell, appCmd,oShellExec
Set oShell = CreateObject("WScript.Shell")

appCmd = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ""&c:/temp/Get_Win_SVC.ps1"" "

Set oShellExec = oShell.Exec(appCmd)

WScript.Sleep 1000
oShellExec.StdIn.Close()

Powershell script:

$username = 'QA\xxxxx'
$password = 'xxxxx'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

(Get-WmiObject  -computer qa-xxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")


$svc = (Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'") 

Write-Host  $svc

$svc.InvokeMethod("StartService", $null)


(Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")> c:\temp\win_stat_post.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文