我们有一个更新程序,可以自动发布WebDeploy包到IIS服务器。这个程序对于MVC 5应用程序来说非常好用,但对于.Net Core应用程序来说却不行。我们使用Microsoft.Web.Deployment - API,并且我的发布方法如下所示:
我没有收到任何错误信息,但是网站没有发生改变。
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
);
}
}
我没有收到任何错误信息,但是网站没有发生改变。
/t:PackagePublish
时,它总是返回错误信息:“项目中不存在目标“PackagePublish””。这仍然是正确的方法吗? - Doctor Blueerror MSB4041: 项目的默认 XML 命名空间必须是 MSBuild XML 命名空间。如果该项目是使用 MSBuild 2003 格式编写的,请将 xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 添加到 <Project> 元素中。如果该项目是使用旧的 1.0 或 1.2 格式编写的,请将其转换为 MSBuild 2003 格式。
我完全不知道如何部署 .NET Core 应用程序! - Tom"c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild" /p:DeployOnBuild=true /p:WebPublishMethod=package
来源:https://www.dotnetcatch.com/2018/06/13/webdeploy-packaging-with-asp-net-core-2-0-includes-function-apps/ - cederlof