Search code examples
asp.netiisweb-deploymentmsdeployapplication-pool

Run msdeploy.exe from under DefaultAppPool produces weird behaviour


Intro

I have this ASP.NET web app and I'd like to provide its users a way to update the app via POST request with zip file which contains the newer version of the app.

While successefully receiving, storing and using the zip file, I found that msdeploy.exe program does not work, meaning my app is not getting updated.

I am using the following command line syntax:

msdeploy -verb:sync -source:package={0} -dest:auto -enableRule:DoNotDeleteRule

(where {0} is replaced by enquoted full path to the zip file)

The issue

While successefully installing the update via Windows© Shell manually, I fail to do so when I start msdeploy from withing my web application. The code I'm using:

ProcessStartInfo info = new ProcessStartInfo()
{
    FileName = Path.Combine(workingDir, "msdeploy.exe"),
    WorkingDirectory = workingDir,
    CreateNoWindow = true,
    Arguments = @"-verb:sync -source:package={0} -dest:auto -enableRule:DoNotDeleteRule -verbose".Formatted(filename.Enquote()),
    UseShellExecute = false,
    RedirectStandardOutput = true,
};

Process deploy = Process.Start(info);
deploy.Start();

Debugging attempts

I have redirected the program's output into a file so I could compare it to the ideal one, the manual way one which actually works.

Working msdeploy output (run via my windows account + windows shell):

Info: Updating file (Default Web Site/ElQueue\bin\AutoMapper.dll).
Info: Updating file (Default Web Site/ElQueue\bin\Contracts.dll).
...
Info: Updating file (Default Web Site/ElQueue\Views\Web.config).
Info: Updating file (Default Web Site/ElQueue\Web.config).
Info: Adding ACL's for path (Default Web Site/ElQueue)
Info: Adding ACL's for path (Default Web Site/ElQueue)
Total changes: 27 (1 added, 0 deleted, 26 updated, 0 parameters changed, 803122 bytes copied)

Non-working msdeploy output (run via Process.Start hence IIS AppPool\DefaultAppPool IIS' virtual account):

Warning: BACKUP_FAILED - Skipping backup because it failed due to an unknown reason.яFor more information, contact your server administrator.
Info: Adding sitemanifest (sitemanifest).
Info: Creating application (Default Web Site/ElQueue)

And, that's all. Not much. No file updates, no nothing. The application's files remain unchanged.

SO, how to update my web app the right way?

I thought msdeploy is the way, but its seems not to work with default IIS app pool.


Solution

  • Solved the problem by adding a IIS AppPool\DefaultAppPool user into Administrators group via lusrmgr.msc management console tool and also reboot after that.