Вот то, к чему мы пришли:
# 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 за упрощение процесса загрузки + установки.