13

I'm having a bit of a problem with Web Deploy I just can't seem to iron out. Every time I try and publish to WMSvc via the [proj].deploy.cmd command in the package I'm getting "The remote server returned an error: (401) Unauthorized". The command looks like this (project is called "Web", server is named "AutoDeploy"):

Web.deploy.cmd /Y /M:https://AutoDeploy:8172/MsDeploy.axd -allowUntrusted

I can publish fine to https://AutoDeploy:8172/MsDeploy.axd via Visual Studio so the service is definitely running and I can successfully authenticate to it as administrator. Running this locally on the machine against the package while logged on as administrator (it's just a little local Win 2k8 VPC) isn't working and adding /U and /P parameters with the administrator account does nothing.

I've enabled failed request tracing and am getting this output so at least there's something to refer to but unfortunately I can't determine what the root cause is. I'm trying to connect to the same service with the same credentials as in Visual Studio but obviously something is different.

Just out of interest, I can publish fine to the Web Deployment Agent Service (MsDepSvc) as follows:

Web.deploy.cmd /Y /M:http://AutoDeploy/MsDeployAgentService /U:AutoDeploy\Administrator /P:...

But I really want to get WMSvc running! Any thoughts?

Troy Hunt
  • 20,345
  • 13
  • 96
  • 151
  • You should take a look in output window for the command that VS is executing then compare that to what the .cmd file is executing. If you do not see the command in output window then increase verbosity in ools->Options->Projects and Solutions->Build and Run => MSBuild project build output verbosity – Sayed Ibrahim Hashimi Nov 16 '10 at 06:38
  • Thanks Sayed, that got me pointed in the right direction. I'll answer my own question with the solution. – Troy Hunt Nov 17 '10 at 02:42
  • Have you deploy with an IIS Manager User? See my question here: http://stackoverflow.com/questions/7750800/error-user-unauthorized-when-deploy-to-iis-7-5-when-using-iis-manager-user – Tomas Jansson Oct 13 '11 at 07:35

1 Answers1

11

Sayed's comment above got me pointed in the right direction. After making the build output verbosity "Detailed" and also setting UseMsdeployExe to true in the .csproj (another tip from Sayed's blog), I found the command generated by Visual Studio was setting the authentication type to basic which retrospectively, is obvious given the plain text username and password.

The MSDN post on How to: Install a Deployment Package Using the deploy.cmd File explains you can just add an "a" flag to the command to set this. So in short, here's how it now looks (and actually works):

Web.deploy.cmd /Y /M:http://AutoDeploy/MsDeployAgentService /U:AutoDeploy\Administrator /P:...  /A:Basic
Troy Hunt
  • 20,345
  • 13
  • 96
  • 151