【问题标题】:How to deploy windows services using MSBuild?如何使用 MSBuild 部署 Windows 服务?
【发布时间】:2013-04-01 21:27:39
【问题描述】:

我使用 Visual Studio 创建了一个 Windows 服务项目,需要使用 MSBuild 将其安装到远程计算机上。我查看了很多关于部署 Windows 服务的好方法的资源。大多数答案是使用我认为可以替代的 PowerShell 脚本。

谁能给我提供好的资源。关于如何部署它的任何想法。在企业环境中部署(.exe)文件存在很多安全问题,所以我担心选择任何替代方案。

我将非常感谢任何建议。

【问题讨论】:

  • MSBuild 是 Visual Studio 的构建系统。你需要Windows Installer
  • 它是一个包含设置文件的 Visual Studio 解决方案
  • MSBuild 是在 Visual Studio 中编译和构建任何解决方案的工具。你不能用它来安装任何东西。使用 Windows 服务将安装项目添加到您的解决方案中,并使用安装项目的输出安装到您的远程计算机上。
  • msbuild 比 VS 构建系统要广泛得多。它不仅限于VS。但这并不能改变您不使用它进行部署的事实。

标签: c# msbuild windows-services continuous-integration


【解决方案1】:

您可以使用 MSBuild 安装示例:

<MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="SomeWindowsService" User="UserLocal" Password="PassLocal" ServicePath="\\RemoteComp2\PathForYourService\WindowsService.exe" RemoteUser="UserRemoteComp2" RemoteUserPassword="PassRemoteComp2" MachineName="RemoteComp2"/>

更多信息请查看链接http://www.msbuildextensionpack.com/help/4.0.5.0/html/258a18b7-2cf7-330b-e6fe-8bc45db381b9.htm

【讨论】:

    【解决方案2】:

    您可以使用 Exec Task (http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx) 查看链接。

    使用 powershell 远程处理肯定是另一种选择。

    【讨论】:

      【解决方案3】:

      要将服务安装到远程计算机,您可以尝试可以控制 Windows 服务的 ServiceController 任务。来自here

      【讨论】:

        【解决方案4】:

        根据您的要求和部署方案查看 PSExec (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx)。它与 MSBuild Exec 任务相结合,可让您远程安装服务。

        【讨论】:

        • 当我使用此方法时,我的服务中有远程路径(\\\\
        猜你喜欢
        • 1970-01-01
        • 2015-05-26
        • 1970-01-01
        • 1970-01-01
        • 2011-06-12
        • 1970-01-01
        • 2013-02-22
        • 1970-01-01
        • 2010-10-02
        相关资源
        最近更新 更多