In theory, msdeploy is perfect to deploy to IIS, but it was written for cmd, not for powershell. That means that when you call it from a powershell script, things start to fall appart…
I was pretty sure that I would find people who were doing the same thing on github, and indeed, It didn’t take long to find a trusted source: the NugetGallery website deployment script uses msdeploy
It was helpful, but that was not it… Ready to do the things the right way, I did not want to use an administrator account in my script as MSDeploy seems to want it.
And apparently there are ways to use a standard user with just the necessary rights.
The user you create on the machine where you want to deploy, needs to have the ACL rights to the folder of course, and he also needs to have the IIS Manager permission on the application that you want to deploy. You then deploy to the Web Site url (for example, “Default Web Site”) but you give an extra parameter to msdeploy that points to the Web Applilcation this time.
Summarized, it’s something like this :
But somehow that would not work, and the error message was not really helpful. It turns out, as most of the time, that I was doing it wrong (but in that case MSDeploy is really making it easy to shoot yourself in the foot)
I published the complete powershell wrapper that I use as a gist on github, I hope this helps someone. :)