2
我們有一個Update-Program,可以將WebDeploy-Packages自動發佈到IIS服務器。本程序適用於MVC 5 - 應用程序,但不適用於.Net核心應用程序。我們使用Microsoft.Web.Deployment - API和我publishmethod看起來是這樣的:如何將WebDeploy與ASP.Net核心一起使用
private void UpdateIIS(DTOs.ApplicationConfiguration.ApplicationServer applicationServer, DTOs.Update.Update update) {
// SSL-Zertifikatsfehler ignorieren
System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => { return true; });
var sourceBaseOptions = new DeploymentBaseOptions();
var destBaseOptions = new DeploymentBaseOptions() {
ComputerName = string.Format("https://{0}:{1}/msdeploy.axd?site={2}", applicationServer.Adresse, applicationServer.MSDeployPort, applicationServer.SiteName),
UserName = applicationServer.User,
Password = applicationServer.Passwort,
AuthenticationType = "Basic"
};
string updatePackage = Directory.GetFiles(update.UpdateDirectory, "*.zip").FirstOrDefault();
if (!File.Exists(updatePackage)) {
throw new Exception("Update-Paketdatei nicht gefunden");
}
using (var deploymentObject = DeploymentManager.CreateObject(
DeploymentWellKnownProvider.Package,
updatePackage,
sourceBaseOptions)
) {
if (deploymentObject.SyncParameters.Count > 0) {
deploymentObject
.SyncParameters
.Single(p => p.Name == "IIS Web Application Name")
.Value = applicationServer.SiteName;
}
var syncOptions = new DeploymentSyncOptions();
var changes = deploymentObject.SyncTo(
DeploymentWellKnownProvider.Auto,
"",
destBaseOptions,
syncOptions
);
}
}
我沒有錯誤,但網站並沒有改變。
不管出於什麼原因,'/噸:PackagePublish'總是與錯誤'目標「PackagePublish」返回不存在該項目'當我嘗試了。這仍然是要走的路嗎? – Scott
您使用的是什麼版本的Core? – chief7
看起來像1.1.1(最近安裝它,所以你可以假設最新版本)。 – Scott