使用 Microsoft.Web.Deployment 部署 Web 应用程序
我已经能够使用 Microsoft.Web.Deployment 代码将文件放置在我的 IIS 服务器上:
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);
看起来这一切所做的就是在现有 Web 应用程序下创建一个新文件夹。如果我进入 IIS 管理器,右键单击我创建的文件夹,然后单击“转换为应用程序”,然后我就会得到我正在寻找的行为。有谁知道如何仅使用 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,多亏了您的代码,我才成功将我的网站部署到云上。所以它应该有效:P
Actually thanks to your code I managed to deploy my websites to cloud. So it should work :P
您可以将以下行添加到代码中,
其中
parameters
是
.SetParameters.xml 文件的完整路径。在此文件中,您指定虚拟应用程序名称:
You can add the following lines to your code
where
parameters
is the full path to your<project>
.SetParameters.xml file.In this file, you specify the virtual application name: