CALL US

888.221.5905

.NET Debug

We all might try to pretend that the code we wrote is perfect and will never break, but if there is one constant in Software Development it is that no matter how genius you were when you wrote your code, you are bound to run into bugs. As every developer is all too aware, debugging can present a real challenge, particularly when the code must be executed from within a specialized environment remote from the developers own computer.

As .NET developers we have transitioned our model to a Cloud First mentality which is to say that all of our processes must¬†work in the cloud including the ability to debug our code. When I found myself suddenly needing to reach out to the Cloud as any developer would I began researching what options were available. It didn’t take long for me to find out that Visual Studio offers free Remote Tools. Unfortunately every article I read seemed to be either out of date or leave just enough information out that it ultimately led me in circles.

From vNow to vNext, .NET provides one of the friendliest environments for working Cloud First once you understand the tools at your disposal. Regardless of what type of .NET application you have deployed on your Windows Cloud Server, Visual Studio provides you with an easy out of box solution for securely connecting to your live code in the Cloud. While every development situation is a little different, one of the common one’s that I see today is for the Web App Developer. With that in mind here’s a simple guide to go from a fresh Cloud Server to a Web Server that you as a developer can fully utilize to debug your code.

Checklist:

  • CARI.net Windows Cloud Server
  • Add any Local or Domain Users and Groups that should have access to the Remote Debugging Tools to the Local Administrators Group.

Step 1:

  • Perhaps this should go without saying, but Install the Web Server (IIS) Role. This can be done manually or by using either Web Platform Installer or the included script.

Step 2:

  • Install Web Deploy 3.5 if you want to deploy your solution directly from within Visual Studio. This should be done from within Web Platform Installer or the included script.

Cheat:

  • Use this PowerShell script to configure the WebServer Role with Web Deploy ( Steps 1 & 2 )

– OR –

  • Install Web Platform Installer. Install the following packages:
  • Recommended IIS Configuration ( Step 1 )
  • Web Deploy 3.5 ( Step 2 )

– OR –

  • Recommended IIS Configuration for Hosting Providers ( Steps 1 & 2 )
    • This includes Web Deploy, PHP 5.3, PHP 5.5, and Node.JS

You should also verify that all of the Features of the Web Server you want are installed.

Step 3:

Download and Install the Remote Tools for the version of Visual Studio you have installed and will be using. The installation process is extremely simple, simply agree to the license and click Install.

Remote Tools Installer
The installer has the same easy flow for vNow to vNext. Agree to the Terms and Conditions and click Install.

 

Following the installation you will need to open the Remote Debugger Configuration Wizard from the Start menu. Since it just seems like a bad practice to leave your server open to anyone to be able to connect to the processes, my suggestion would be to opt for running the Remote Tools as a service. You can use any account you want though running it as the Local System should be fine for most applications.

Note that there is an option for the Remote Debugger and the Remote Debugger Configuration Wizard. You want the Wizard to set it up as a service.
Note that there is an option for the Remote Debugger and the Remote Debugger Configuration Wizard. You want the Wizard to set it up as a service.

 

Remote Tools Configuration1

Remote Tools Configuration2
Check the box to run as a Service. Leave the User name as LocalSystem or enter the User Credentials you want the service to run as.

 

Once you’ve configured the Remote Tools to run as a Service; your server is ready for Cloud Development. If you open your Visual Studio Project simply right click the Project and select Publish.

 

Right Click your ASP.NET Project and Click on Publish
Right Click your ASP.NET Project and Click on Publish

The first time you do this it will ask you to create a Publish Profile. You can manually configure a custom profile or a Publish Profile that was exported from IIS on your server.

 

Click on Custom or Import an existing Publish Profile
Click on Custom or Import an existing Publish Profile

The Publish Process is fairly straight forward. If you used the Script provided here you can configure Web Deploy to use either Local Administrator Accounts or any custom User whether it’s a Windows Account or IIS User.

 

Enter the connection details for the Publish Profile. The Server could be an IP or FQDN. The Site Name must be what the name of the site is in IIS. The username and password can be either an authorized Windows Account or IIS User.
Enter the connection details for the Publish Profile. The Server could be an IP or FQDN. The Site Name must be what the name of the site is in IIS. The username and password can be either an authorized Windows Account or IIS User.

 

Using a custom user is as simple as right clicking on the Web Site in IIS Manager, selecting Deploy => “Configure Web Deploy Publishing…” and select a User to give permissions to.

After deploying your web application from Visual Studio click on Tools => “Attach to Process…” ( Alt + Ctrl + P ).
Attach To Process

The Qualifier name will display your local machine name. To attach to the Web Server update the Qualifier to the IP or FQDN of your Web Server, and click Refresh. This will prompt you for user credentials, and may be any domain or local Windows Account which is an A
dministrator on your Web Server. Note that if the account you connected with is not the account that the IIS APP Pool for your site is using you will need to check the box to “Show processes from all users”. The process you will want to look for is w3wp.exe being executed by the App Pool. By default this is “IIS APPPOOL\DefaulAppPool”.

 

Attach To Process
You will need to log in with a Windows Account that is a member of the local Administrators. If the account you logged in with is not the same as the account your website is running as you will need to Show processes from all users and refresh.

With the Remote Debugger attached to the process you can now continue to execute your normal debugging processes. Each breakpoint you have set in Visual Studio will attach itself to the remote process and the entire debugging process will work every bit as simply as when you try to execute your code locally. Breakpoints attached, working in the Cloud was never so simple until now.

Click Here to Download the Configuration Script

The first step to debugging your code in the cloud is to get your Windows cloud server from CARI.net To get the ball rolling start here.

Leave a Reply

WE ARE HERE FOR YOU

WRITE TO US

SEND US AN EMAIL

SUPPORT

LIVE CHAT

CARI.net
8929 Complex Drive
San Diego, CA 92123
© Copyright 2014 CARI.net

SUBSCRIBE

Latest headlines, offers and new services delivered to you daily

WE ARE SOCIAL

You can find us in the different social networks.