Deploying a Web Application using Microsoft.Web.Deployment
Asked Answered
P

2

10

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?

Primordial answered 30/3, 2011 at 21:0 Comment(0)
W
3

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);
        }
Wickner answered 9/10, 2012 at 10:47 Comment(0)
P
1

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>" />'
Pleonasm answered 27/11, 2013 at 15:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.