我正在为开发环境创建一个Service Fabric集群,它需要使用Powershell DSC在每个节点上安装和运行Visual Studio 2017远程调试器。
我们的DSC脚本成功复制了vs2017远程工具安装程序,并进行无人值守安装,但我们很难将其作为服务运行并使用正确的防火墙设置。
答案 0 :(得分:0)
以下是我们最终的目标:
# Download and configure Chocolaty
cChocoInstaller InstallChoco
{
InstallDir = "C:\choco"
}
# Download and install VS2017 Remote Debugger
cChocoPackageInstaller InstallRemoteDebugger
{
Name = "visualstudio2017-remotetools"
Version = "15.0.26430.2"
Source = “https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/manual/visualstudio2017-remotetools”
DependsOn = "[cChocoInstaller]installChoco"
}
# Install the remote debugger and run as a service
Script ConfigureRemoteDebugger {
GetScript = { @{ Result = "" } }
TestScript = {
$msvsmonPathx64 = 'C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe'
$serviceName = "msvsmon150"
$result = $true
# Validate the VS2017 Remote Debugger is installed to the harddrive
$result = $result -and (Test-Path $msvsmonPathx64)
# Verify the service exists and is running
if ($service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
if ($service.Status -eq "Running") {
$result = $result -and $true
}
else {
$result = $result -and $false
}
}
else {
$result = $result -and $false
}
return $result
}
SetScript =
{
# Run as service
$startDebugger = $true
$remoteDebugExe = "`"C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\rdbgservice.exe`" msvsmon150"
$serviceName = "msvsmon150"
$serviceDisplayName = "Visual Studio 2017 Remote Debugger"
$serviceDescription = "Allows members of the Administrators group to remotely debug server applications using Visual Studio. Use the Visual Studio Remote Debugging Configuration Wizard to enable this service."
if (!(Get-Service -Name msvsmon150 -ErrorAction SilentlyContinue)) {
New-Service -Name $serviceName -BinaryPathName $remoteDebugExe -DisplayName $serviceDisplayName -Description $serviceDescription
}
if ($startDebugger -eq $false) {
Set-Service -Name $serviceName -StartupType Manual
}
else {
Set-Service -Name $serviceName -StartupType Automatic
Start-Service -Name $serviceName
}
}
Credential = $serviceAccountCredential
DependsOn = "[cChocoPackageInstaller]InstallRemoteDebugger"
}
注意:您的DSC可能需要配置防火墙以允许远程调试器,否则您将无法连接。
向Chocolatey致敬,使下载+安装过程变得如此简单。