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?
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);
}
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>" />'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With