Search code examples
profilingvisual-studio-2022profiler

Visual studio 2022 remote profiler


Good afternoon.

Faced with the need to profile remote execution of the program (Dot Net Core 3.1, AtraLinux). When developing a program, I use Visual Studio 2022 on Windows 10. I know that Visual Studio 2022 has a rich selection of profilers, as a result of this the question arises:

Can Visial Studio 2022 profile my remote execution?

P.S: Found a similar question only for Visual Studio 2013.

enter link description here


Solution

  • I submitted a documentation issue on GitHub in regards to the following Microsoft page, as it did not provide sufficient information to answer the question about remote profiling: https://learn.microsoft.com/en-us/visualstudio/profiling/profile-apps-from-command-line

    Fortunately, Microsoft was kind enough to research and update the documentation with clearer information on how to accomplish this.

    It turns out that the key to performing remote profiling is to not only have the Visual Studio Remote Tools installed on the remote machine, but to actually run the command line profiler directly on/from within the remote machine. So you are essentially doing local profiling of your application, but saving it to a file, and then later on copying the file over to your own machine to open up and analyze the recorded profiling file in Visual Studio.

    So from step 2 in the new instructions on the Microsoft page, it says:

    For the remote tools, the collection agent executable is in this location:

    Program Files\Microsoft Visual Studio 17.0\Team Tools\DiagnosticsHub\Collector\

    Note

    When using the command line in remote scenarios, you need to run the command-line instructions on the remote machine. If you want to attach to the remote machine from Visual Studio, use the Performance Profiler in Visual Studio instead.

    And then you would continue on with step 3, in the command prompt on your remote machine with:

    Start VSDiagnostics.exe by typing the following command.

    VSDiagnostics.exe start <id> /attach:<pid> /loadConfig:<configFile>

    Hope that helps.