Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用MSBuild部署windows服务?_C#_Msbuild_Windows Services_Continuous Integration - Fatal编程技术网

C# 如何使用MSBuild部署windows服务?

C# 如何使用MSBuild部署windows服务?,c#,msbuild,windows-services,continuous-integration,C#,Msbuild,Windows Services,Continuous Integration,我使用Visual Studio创建了一个windows服务项目,该项目需要使用MSBuild安装到远程计算机上。我看过很多关于部署windows服务的好方法的参考资料。大多数答案是使用PowerShell脚本,我认为这是一种替代方法 谁能给我提供好的资源。关于如何部署它的任何想法。在企业环境中部署(.exe)文件存在许多安全问题,因此我担心是否会选择其他替代方案 我非常感谢您的建议。若要将服务安装到远程计算机,您可以尝试可以控制Windows服务的ServiceController任务。从。可

我使用Visual Studio创建了一个windows服务项目,该项目需要使用MSBuild安装到远程计算机上。我看过很多关于部署windows服务的好方法的参考资料。大多数答案是使用PowerShell脚本,我认为这是一种替代方法

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


我非常感谢您的建议。

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

可以使用Exec Task()查看链接

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

根据您的需求和部署场景,查看PSExec()。它与MSBuild Exec任务结合使用,将允许您远程安装该服务。

您可以使用MSBuild 安装示例:

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


有关详细信息,请查看follow link

MSBuild是Visual Studio的生成系统。您需要一个包含安装文件的visual studio解决方案MSBuild是在visual studio中编译和生成任何解决方案的工具。你不能用它来安装任何东西。使用Windows服务将安装项目添加到解决方案中,并使用安装项目的输出在远程计算机上进行安装。msbuild比VS build系统要广泛得多。它不限于VS,但这不会改变您不使用它进行部署的事实。当我使用此方法时,我的服务中有远程路径(\\\\