I think I can code
I think I can code

Reputation: 647

Symbols not loading for remote debugging on ASP.Net app built and deployed from Azure DevOps Pipeline

I have an ASP.Net application who's code is sitting in an Azure Repo. The project has a build pipeline that builds on master branch merges. I then have a Deployment pipeline that takes the latest build and deploys local on my web server through a deployment pool I have running on my server. The web application builds with the VS Build task and deploys with the IIS Web App Deploy task. Both work fine.

I have one VM in with Visual Studio that I am trying to use to remote debug the web server. I have VS Remote Tools on the web server and it successfully runs. On my VM, I am able to open VS, attach debugger to a remote process on the web server successfully. The problem is that the symbols are not loading and I'm not sure what the correct sequence of items is here.

First, it doesn't appear that there are any .pdb files in the build produced by the Azure Pipeline. Second, I'm not sure what is the proper way to get the code onto the VM for debugging (Clone repo, vs download zip, etc). Third, I attempted to add a Publish Smybols task to my deploy pipeline, however its generating .pdb folders not files, and I'm not sure where to place these either on the web server, or on the vm.

My background is in classic local TFS setups, so working, building and deploying from Azure DevOps has me confused on how to get remote debugging to work.

Upvotes: 1

Views: 3332

Answers (1)

bendecko
bendecko

Reputation: 2783

OK this is not for the faint-hearted. It has taken me 3hrs to slowly work through this - but it's worth it. Many times has something worked locally, but then when you trigger an Build Agent with CI on a remote server you can't Step through the code with breakpoints.

So this info is if you are using the above situation - Azure build agent and Continuous Integration. If you are using a Publish Profile this doesn't apply.

First things first... The most important parts of this answer can be found in this blog:

https://willys-cave.ghost.io/i-have-a-dream-of-a-single-build-consistent-x-and-simple/

I've added that Url to the wayback machine at archive.org in case it disappears.

So yes the problem is the .PDB files - they need to be included by adding Publish symbols task. in your VSO pipeline.

Note: I had to change the BuildConfiguration parameter to debug (different from Willy's instructions). Otherwise when you eventually start to hit breakpoints the code is optimized and you won't see variable values in the hover-over etc.

In VS 2019 Willy's instruction for Link to the symbols during remote debugging sessions needs reading carefully. I didn't. There is a better image on:

https://devblogs.microsoft.com/devops/vsts-is-now-a-symbol-server/

I include the screen capture here:

enter image description here

Importantly you need to add your VSTS hostname into the list of Symbol Servers

Now mine still wasn't hitting the breakpoints and I found this page (which is generally about using the slightly different method of Publish Profiles), but I noticed some more components were loaded into IIS... Yes! You may need these too.

https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-azure?view=vs-2019

So the most important image I will paste here:

enter image description here

You need to add IIS Management Scripts and Tools to your IIS installation.

That should do it. Also I run my remote debugger as Administrator, attach it to the w3wp.exe (show All Users Processes) and if it doesn't appear - reload the remote page and Refresh as if the pool goes to sleep you won't see it in the list

enter image description here

Good luck!

Upvotes: 4

Related Questions