【问题标题】:Azure ARM DSC - install VS2017 remote debuggerAzure ARM DSC - 安装 VS2017 远程调试器
【发布时间】:2018-10-14 06:41:33
【问题描述】:
我正在为开发环境创建一个 Service Fabric 群集,该环境需要使用 Powershell DSC 在每个节点上安装并作为服务运行 Visual Studio 2017 远程调试器。
我们的 DSC 脚本成功复制了 vs2017 远程工具安装程序并进行了无人值守安装,但我们正在努力让它作为服务运行并使用正确的防火墙设置。
【问题讨论】:
标签:
visual-studio-2017
remote-debugging
dsc
azure-automation
【解决方案1】:
这是我们最终的结果:
# 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 让下载+安装过程变得如此简单。