Attaching the remote debugger

This document describes how to attach the Visual Studio remote debugger to processes on a Compute Engine Virtual Machine running Windows.

Prerequisites

Before you begin, ensure your virtual machine meets the following prerequisites:

  • Running the Windows operating system

  • Has a public IP address

  • Has Remote PowerShell installed and enabled

    • If you don't want to enable Remote PowerShell connection, or if it's not installed on the VM, you can find steps to install the Visual Studio Debugger Remote Tools manually by searching for MSDN Visual Studio Remote Debugging.

    • You can also add firewall rules to unblock the Debugger Remote Tool port.

You can deploy an ASP.NET framework image that meets all of these prerequisites.

Attaching the remote debugger

To attach the remote debugger:

  1. Select Tools > Google Cloud Tools > Show Google Cloud Explorer to launch the Cloud Explorer.

  2. Right click the Compute Engine VM instance you want to attach the remote debugger to and select Attach debugger.

    The attach debugger wizard displays.

  3. Click OK when prompted to add firewall rules to allow traffic to the required ports.

    1. The Learn more link in the dialog takes you to the Opening firewall ports section for more information.
  4. Select the process to debug and click OK.

Note the following:

  • The first time you connect to a remote VM instance, the wizard installs Visual Studio Debugger Remote Tools for you. This installation can take some time if the VM is in a different region.

  • The debugger tools are installed in Program Files\VisualStudioRemoteTools on the target machine.

  • In Visual Studio 2015, the Watch window does not show local variables. You need to use Visual Studio 2017 to inspect local variables.

  • You must load symbols manually if you optimize your release build:

    1. As you are debugging your application, select Debug > Windows > Modules.

    2. Locate your debuggee assembly.

    3. Right click the appropriate entry and select Load Symbols.

Opening firewall ports

To enable remote debugging, you need to add firewall rules to allow traffic to the target machine and enable connection to the Debugging Remote Tools. For Visual Studio 2015, the port is 4020; for Visual Studio 2017, the port is 4022.

Cloud Tools for Visual Studio can install and start remote tools for you using a remote PowerShell connection. You first must enable remote PowerShell HTTPs port 5986.

When you are finished debugging, remove the firewall rules:

  1. Select Tools > Google Cloud Tools > Show Google Cloud Explorer to launch the Cloud Explorer.

  2. Right click the Compute Engine VM instance and select Firewall Options....

  3. Clear the checkboxes for the Allow Visual Studio Debugger connections to the instance and the Allow Remote PowerShell HTTPs traffic to the instance firewall rules.

  4. Click Save to remove the firewall rules.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Tools for Visual Studio