Sunday, March 27, 2016

Remote debugging Azure Web Sites With Visual Studio

When I want to debug Azure Web Sites using Visual Studio, I got a login dialog window message that "visual studio 2015 enter your credentials for azure websites"


Then I found the below site where instructions has been given how to remote authenticate into VS for debugging Azure Web Sites

Remote Debugging Azure Web Sites

The below contents are taken from the above site

You can also remotely debug your Windows Azure Web Site with Visual Studio 2012, but you’ll need to configure a few things manually for now. We are working to bring the same experience for remote debugging to Visual Studio 2012 but we are not there yet. For now you can use the steps below for Visual Studio 2012.
  1. In the Windows Azure Management Portal, go to the Configure tab for your web site, and then scroll down to the Site Diagnostics section
  2. Set Remote Debugging to On, and set Remote Debugging Visual Studio Version to 2012 
image
  1. In the Visual Studio Debug menu, click Attach to Process
  2. In the Qualifier box, enter the URL for your web site, without the http:// prefix
  3. Select Show processes from all users
  4. When you’re prompted for credentials, enter the user name and password that has permissions to publish the web site. To get these credentials, go to the Dashboard tab for your web site in the management portal and click Download the publish profile. Open the file in a text editor, and you’ll find the user name and password after the first occurrences of userName= and userPWD=.
  5. When the processes appear in the Available Processes table, select w3wp.exe, and then click Attach.
  6. Open a browser to your site URL.
    • You might have to wait 20 seconds or so while Windows Azure sets up the server for debugging. This delay only happens the first time you run in debug mode on a web site. Subsequent times within the next 48 hours when you start debugging again there won’t be a delay.

Saturday, March 26, 2016

When deploying DNX projects to Azure, some times we may get the error saying that "File Path too long"

When deploying DNX projects to Azure, some times we may get the error saying that "File Path too long".

When I am deploying the DNX project to Azure, I got the below error

The "Dnu" task failed unexpectedly.
System.Exception:
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
Copying to output path C:\Users\v-lapedd\AppData\Local\Temp\PublishTemp\Microsoft.Legal.MatterCenter.Service116

Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at Microsoft.DNX.Tasks.Dnu.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()


The reason for this is, by default Visual Studio will use the below directory
"C:\Users\v-lapedd\AppData\Local\Temp\PublishTemp" to create the package and from there deploy the file to Azure.

Sometimes, the path of the deployed package will be such that it will exceed NTFS file system path limit which is 248.

If you look into that folder structure of the PublishTemp folder and the approot in that folder and the Packages in that folder, it contains all the packages that are used in your project.

Sometimes the package folder will be long based the namespace of the project. For ex, there is one nugget package with in the deploy folder which is more than 248 characters


C:\Users\profilename\AppData\Local\Temp\PublishTemp\Microsoft.Legal.MatterCenter.Service116\approot\packages\Microsoft.Extensions.Configuration.EnvironmentVariables\1.0.0-rc1-final\lib\dotnet5.4\Microsoft.Extensions.Configuration.EnvironmentVariables.dll
 
 
 
Solution
One solution to this one will be, controlling the publish folder path. Instead of publishing the project to default path which visual studio uses, if we publish to any path which is short, then this issue will be solved.

How to change the project deployment path of DNX or Asp.Net Core 1.0 project?

Here are the steps:

1. Open the project (xproj) that you want to deploy to Azure or to any other location in any text editor

2. Then add the below xml code below the node

 
 


Note: Take care that there are no training "\" at the end of the folder path that you have given. If there is any trailing "\", you will get the error saying that, "Illegal Characters in the path"

Correct path: C:\Temp\Publish

Wrong path: C:\Temp\Publish\

3. Save the project file

4. Open the solution again in visual studio and publish the file and the project and this time the publish should succeed


Here is the modified xproj file