作者:火星人平凡五哥 | 来源:互联网 | 2023-10-13 11:27
Wereusingthe(almostcompletleyundocumented)publicAPIforWebDeploy3tocreatea.zippack
We're using the (almost completley undocumented) 'public API' for Web Deploy 3 to create a .zip package of our website and then sync it to a server:
我们正在使用(几乎完全没有文档)“公共API”用于Web部署3,用于创建我们网站的.zip包,然后将其同步到服务器:
DeploymentBaseOptions destinatiOnOptions= new DeploymentBaseOptions()
{
UserName = //username,
Password = //password,
ComputerName = //a server
};
using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.Package, "C:/MyWebsitePackage.zip"))
{
deploymentObject.SyncParameters.Load(packageParametersFile); \\ contains some connection string information and nothing more.
DeploymentSyncOptions syncOptiOns= new DeploymentSyncOptions();
syncOptions.WhatIf = false;
deploymentObject.SyncTo(destinationOptions, syncOptions);
}
This code worked perfectly until we installed .NET 4.5 on our production and build servers and upgraded the project we are deploying to 4.5 also. Now we're getting the following error:
这段代码运行得非常好,直到我们在产品上安装了。net 4.5,并构建服务器,并将正在部署的项目升级到4.5。现在我们得到了以下错误:
The application pool that you are trying to use has the 'managedRuntimeVersion' property set to 'v4.0'. This application requires 'v4.5'. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_APPPOOL_VERSION_MISMATCH.
您正在尝试使用的应用程序池的“managedRuntimeVersion”属性设置为“v4.0”。这个应用程序需要“v4.5开发”。了解更多:http://go.microsoft.com/fwlink/?LinkId=221672 ERROR_APPPOOL_VERSION_MISMATCH。
Our server definately has .Net 4.5 installed and the and the IIS web site application pool version is '.NET Framework v4.0.30319' (I know it says v4 but .NET 4.5 is an 'in-place' upgrade and replaces 4.0 DLLs with the new version number .30319).
我们的服务器已经安装了。net 4.5, IIS网站的应用程序池版本是'。NET Framework v4.0.30319'(我知道它说的是v4,但是。NET 4.5是一个“就地”升级,用新版本号为.30319替换了4.0 dll)。
It is possible to resolve this issue when deploying via MSBuild.exe command line (not by creating a package but by syncing directly to a server) by adding the /p:VisualStudioVersion=11.0 flag (which causes a different web application targets file to be used which somehow allows deployment of a .NET 4.5 application).
通过MSBuild部署时可以解决这个问题。通过添加/p:VisualStudioVersion=11.0标志(这会导致使用不同的web应用程序目标文件,以某种方式允许部署. net 4.5应用程序),exe命令行(不是通过创建包,而是通过直接同步到服务器)。
Does anyone know why Web Deploy API complains like this and how I can resolve this error in the same way as the MSBuild solution?
有人知道为什么Web部署API会这样抱怨吗?我如何能够像MSBuild解决方案一样解决这个问题?
2 个解决方案