如何发布 .net 框架 windows 服务
How to publish a .net framework windows service
我有一个使用 .net 核心构建的 windows 服务,我可以使用发布配置文件发布它,因为我使用 appsettings 我也可以针对环境。试图找出另一个项目的解决方案,但它使用 .net 框架并且不想使用 installutil。到目前为止我只能
- 停止服务
- 复制文件
- 重新启动服务
但是,对于 .net 框架服务,设置在 app.config 中,测试服务器和生产服务器之间的设置明显不同。
所以现在我正在考虑使用 powershell 执行此操作,并希望将其添加到构建管道中以使其自动化。这些步骤与 powershell 脚本执行的步骤相同
- 停止目标服务器上的服务
- 复制 /bin 文件夹中的文件
- 在目标服务器上重新启动服务
除了在复制文件之后,我需要修改 app.config,以上所有我确信我可以用 powershell 完成。
我的问题是,这可以通过在本地构建代理上运行的构建管道来完成吗?
can this be done via a build pipeline that runs on a on-prem build
agent
对于这个问题,根据你的情况,正如penaunt在评论中提到的,你可以尝试将PowerShell on target machines任务添加到构建管道中。
您可以使用此任务在远程计算机上执行 PowerShell 脚本。此任务使用 Windows 远程管理 (WinRM) 访问本地物理计算机或已加入域或已加入工作组的虚拟计算机。对于 PowerShell 脚本,计算机必须安装 PowerShell 2.0 或更高版本。
- task: PowerShellOnTargetMachines@3
displayName: 'Run PowerShell on Target Machines'
inputs:
Machines: '...'
#userName: # Optional
#userPassword: # Optional
#scriptType: 'Inline'
#inlineScript: '# Write your powershell commands here'
#scriptArguments: # Optional
我有一个使用 .net 核心构建的 windows 服务,我可以使用发布配置文件发布它,因为我使用 appsettings 我也可以针对环境。试图找出另一个项目的解决方案,但它使用 .net 框架并且不想使用 installutil。到目前为止我只能
- 停止服务
- 复制文件
- 重新启动服务
但是,对于 .net 框架服务,设置在 app.config 中,测试服务器和生产服务器之间的设置明显不同。
所以现在我正在考虑使用 powershell 执行此操作,并希望将其添加到构建管道中以使其自动化。这些步骤与 powershell 脚本执行的步骤相同
- 停止目标服务器上的服务
- 复制 /bin 文件夹中的文件
- 在目标服务器上重新启动服务
除了在复制文件之后,我需要修改 app.config,以上所有我确信我可以用 powershell 完成。
我的问题是,这可以通过在本地构建代理上运行的构建管道来完成吗?
can this be done via a build pipeline that runs on a on-prem build agent
对于这个问题,根据你的情况,正如penaunt在评论中提到的,你可以尝试将PowerShell on target machines任务添加到构建管道中。
您可以使用此任务在远程计算机上执行 PowerShell 脚本。此任务使用 Windows 远程管理 (WinRM) 访问本地物理计算机或已加入域或已加入工作组的虚拟计算机。对于 PowerShell 脚本,计算机必须安装 PowerShell 2.0 或更高版本。
- task: PowerShellOnTargetMachines@3
displayName: 'Run PowerShell on Target Machines'
inputs:
Machines: '...'
#userName: # Optional
#userPassword: # Optional
#scriptType: 'Inline'
#inlineScript: '# Write your powershell commands here'
#scriptArguments: # Optional