热门标签 | 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

推荐阅读
  • ASP.NET MVC中Area机制的实现与优化
    本文探讨了在ASP.NET MVC框架中,如何通过Area机制有效地组织和管理大规模应用程序的不同功能模块。通过合理的文件夹结构和命名规则,开发人员可以更高效地管理和扩展项目。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • 深入解析Redis内存对象模型
    本文详细介绍了Redis内存对象模型的关键知识点,包括内存统计、内存分配、数据存储细节及优化策略。通过实际案例和专业分析,帮助读者全面理解Redis内存管理机制。 ... [详细]
  • Windows服务与数据库交互问题解析
    本文探讨了在Windows 10(64位)环境下开发的Windows服务,旨在定期向本地MS SQL Server (v.11)插入记录。尽管服务已成功安装并运行,但记录并未正确插入。我们将详细分析可能的原因及解决方案。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • 本文探讨了如何优化和正确配置Kafka Streams应用程序以确保准确的状态存储查询。通过调整配置参数和代码逻辑,可以有效解决数据不一致的问题。 ... [详细]
  • 2023年京东Android面试真题解析与经验分享
    本文由一位拥有6年Android开发经验的工程师撰写,详细解析了京东面试中常见的技术问题。涵盖引用传递、Handler机制、ListView优化、多线程控制及ANR处理等核心知识点。 ... [详细]
  • 尽管使用TensorFlow和PyTorch等成熟框架可以显著降低实现递归神经网络(RNN)的门槛,但对于初学者来说,理解其底层原理至关重要。本文将引导您使用NumPy从头构建一个用于自然语言处理(NLP)的RNN模型。 ... [详细]
  • 深入解析 Spring Security 用户认证机制
    本文将详细介绍 Spring Security 中用户登录认证的核心流程,重点分析 AbstractAuthenticationProcessingFilter 和 AuthenticationManager 的工作原理。通过理解这些组件的实现,读者可以更好地掌握 Spring Security 的认证机制。 ... [详细]
  • 在 Flutter 开发过程中,开发者经常会遇到 Widget 构造函数中的可选参数 Key。对于初学者来说,理解 Key 的作用和使用场景可能是一个挑战。本文将详细探讨 Key 的概念及其应用场景,并通过实例帮助你更好地掌握这一重要工具。 ... [详细]
  • 深入理解Redis的数据结构与对象系统
    本文详细探讨了Redis中的数据结构和对象系统的实现,包括字符串、列表、集合、哈希表和有序集合等五种核心对象类型,以及它们所使用的底层数据结构。通过分析源码和相关文献,帮助读者更好地理解Redis的设计原理。 ... [详细]
  • Startup 类配置服务和应用的请求管道。Startup类ASP.NETCore应用使用 Startup 类,按照约定命名为 Startup。 Startup 类:可选择性地包括 ... [详细]
  • 本文详细介绍了如何准备和安装 Eclipse 开发环境及其相关插件,包括 JDK、Tomcat、Struts 等组件的安装步骤及配置方法。 ... [详细]
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社区 版权所有