热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Web部署API——部署.NET4.5应用程序-WebDeployAPI-deploya.NET4.5application

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 个解决方案

#1


11  

Easiest would probably be just including IgnoreDeployManagedRuntimeVersion property from Microsoft.Web.Publishing.targets into the .csproj or as a parameter to MSBuild during /t:package step. Other option might be parameters.xml in project root to make managedRuntimeVersion overwriteable with MSDeploy parameters, or setting it directly in .zip in archive.xml as a predeployment step.

最简单的方法可能就是从Microsoft.Web.Publishing中包含ignoredeployemanagedruntimeversion属性。目标到.csproj中或作为MSBuild在/t:package步骤期间的参数。其他选项可能是参数。使用MSDeploy参数使managedRuntimeVersion可重写,或将其直接设置为.zip存档。作为预部署步骤的xml。

Update (too long to reply as comment):

更新(回复时间太长):

Well, it's less of a hack than what VS 2012 itself does. Do a publish to IIS from VS (the Web Deploy option) and the package it'll generate will ll be the content of temp folder and a parameters xml, not a zip you get when doing a generic packaging, and runtime version wil be set to 4 even though project is 4.5. IgnoreDeployManagedRuntimeVersion simply will omit it completely. If you do Web Deploy Package option from VS you'll get a zip with 4.5 in the archive.xml and if you try to manually import that VS outputted zip into IIS directly, you'll get the error popup with 4.0 vs 4.5 app pool error, same as the one you get from running msbuild /t:package and msdeploy :sync from command line. VS (devenv) doesn't do it "right", it quietly overwrites the project setting, and it's not MSDeploy's fault as version is set during compilation/packaging (MSBuild/devenv) not during deployment.

和2012年相比,这并不是什么大问题。做一个发布到IIS VS(Web部署选项)和包会产生将会临时文件夹和一个参数的xml的内容,不是一个压缩在一个通用的包装,和运行时版本会被设置为4,即使项目是4.5。ignoredeployedruntimeversion会完全省略它。如果你做Web部署包选项从VS,你将得到一个zip与4.5档案。如果您尝试手动将这个VS outputted zip直接导入到IIS中,您将会看到4.0 VS 4.5的应用程序池错误,就像您从命令行运行msbuild /t:package和msdeploy:sync的错误一样。VS (devenv)没有“正确”地做,它悄悄地覆盖项目设置,而且它不是MSDeploy的错误,因为版本是在编译/打包(MSBuild/devenv)期间设置的,而不是在部署期间设置的。

By the way, re API docs, yes they are practically nonexistent, but I find the command line docs tolerable (called Web Deploy not MSDeploy, eg http://technet.microsoft.com/en-us/library/dd569089.aspx and others) and mentally mapping those to dotPeek output helps a little.

顺便说一下,re API文档,它们实际上是不存在的,但是我发现命令行文档是可以接受的(称为Web部署而不是MSDeploy,如http://technet.microsoft.com/en-us/library/dd569089.aspx等),并且在思想上将它们映射到dotPeek输出会有一些帮助。

#2


4  

You can try adding this to your project:

您可以尝试将此添加到项目中:

True

推荐阅读
author-avatar
火星人平凡五哥
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有