gpt4 book ai didi

c# - 使用 Microsoft.Web.Deployment 部署 Web 应用程序

转载 作者:太空狗 更新时间:2023-10-29 17:57:39 25 4
gpt4 key购买 nike

我已经能够使用 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 包来做到这一点?

最佳答案

实际上,多亏了您的代码,我才设法将我的网站部署到云端。所以它应该工作: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);
}

关于c# - 使用 Microsoft.Web.Deployment 部署 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5492316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com