Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying a Web Application using Microsoft.Web.Deployment

I've been able to place files on my IIS server using Microsoft.Web.Deployment code:

DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
DeploymentBaseOptions sourceBaseOptions = new DeploymentBaseOptions();
sourceBaseOptions.ComputerName = "localhost";

DeploymentBaseOptions destinationBaseOptions = new DeploymentBaseOptions();
destinationBaseOptions.ComputerName = ComputerName;  // remote host
destinationBaseOptions.UserName = Username;
destinationBaseOptions.Password = Password;

 DeploymentObject deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.IisApp, deployDirectory, sourceBaseOptions);

 deploymentObject.SyncTo(DeploymentWellKnownProvider.IisApp, RemoteFolderName, destinationBaseOptions, syncOptions);

It seems like all this does is create a new folder underneath an existing web application. If I go into IIS Manager, Right click the folder I created, and click "Convert to Application" then I get the behavior I was looking for. Does anyone know how to do this just using the Microsoft.Web.Deployment package?

like image 359
agrippa Avatar asked Mar 30 '11 21:03

agrippa


2 Answers

Actually thanks to your code I managed to deploy my websites to cloud. So it should work :P

public static void DeployWebsite(string user, string pw, string folder, string domain, string sitename)
        {
            DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
            DeploymentBaseOptions sourceBaseOptions = new DeploymentBaseOptions();
            DeploymentBaseOptions destinationBaseOptions = new DeploymentBaseOptions();

            destinationBaseOptions.ComputerName = domain;
            destinationBaseOptions.UserName = user;
            destinationBaseOptions.Password = pw;

            DeploymentObject deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.IisApp, folder, sourceBaseOptions);
            deploymentObject.SyncTo(DeploymentWellKnownProvider.IisApp, sitename, destinationBaseOptions, syncOptions);
        }
like image 183
WtFudgE Avatar answered Sep 25 '22 11:09

WtFudgE


You can add the following lines to your code

deploymentObject.SyncParameters.Load(parameters);

where parameters is the full path to your <project>.SetParameters.xml file. In this file, you specify the virtual application name:

<setParameter name="IIS Web Application Name" value="<WebSite>/<VirtualApp>" />'
like image 23
Ryan Avatar answered Sep 23 '22 11:09

Ryan