本文介绍了使用 msdeploy & 构建一次并部署到多个环境视觉工作室 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致力于为多种解决方案集中配置、应用设置和连接字符串,同时切换到使用命令行中的 msdeploy 来部署 Web 应用.理想情况下,我希望构建包一次,并在将包部署到每个环境时获得最新的配置.我需要一些关于最佳方法的建议.

Working on centralizing configurations, app settings and connection strings, for multiple solutions, while also switching over to use msdeploy from command line to deploy web apps. Ideally I would want to build the packages once, and get up-to-date configurations as the packages are deployed to each environment. I need some advice on the best approach to take.

  1. 使用Parameters.xml 和SetParameters.xml 文件动态交换设置和连接字符串.请参阅 http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html
  2. 使用 machine.config 或服务器级别的 web.config 文件来存储常见的应用设置和连接字符串.
  3. 使用 https://github.com/sayedihashimi/package-web 的 packageweb NuGet 包这允许将 web.config 转换与 msdeploy 一起使用.
  4. 使用 file 或 configSource 属性以及 SetParameters 来指向不同的配置文件,但必须相对于 Web 根目录.
  5. 使用发布配置文件.看使用发布配置文件部署现有包
  1. Use Parameters.xml and SetParameters.xml file to dynamically swap out settings and connection strings. See http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html
  2. Use machine.config or server level web.config files to store common app settings and connection strings.
  3. Use packageweb NuGet package from https://github.com/sayedihashimi/package-web which enables using web.config transforms with msdeploy.
  4. Use file or configSource attributes along with SetParameters to point to different config files, but must be relative from web root.
  5. Use publish profiles. SeeDeploying an existing package using publish profiles

谢谢

推荐答案

我们使用选项#1,它运行良好.我们使用这种方法部署到大约 30-40 个站点和应用程序.

We use option #1 and it works out well enough. We deploy to about 30-40 sites and applications using this approach.

我认为选项 #2 会给您或开发人员带来麻烦.您要么必须确保在部署时从配置中删除带有设置的部分,要么将它们锁定在服务器上,以便本地配置无法添加它们.

I think option #2 will cause headaches for either you or the developers. You'll either have to make sure the sections with settings are removed from the config on deployment, or lock them on the server so that the local config can't add them.

对于选项 #3,您必须进行多次构建才能获得转换后的配置文件.如果您要部署大量站点,这也不太可行.

For option #3 you will have to do multiple builds to get the transformed config files. It also isn't very feasible if you have a large number of sites to deploy.

选项 #4 可以工作,但您可能会在此处遇到限制.要么整个​​部分在一个单独的文件中,要么全部在主文件中,所以没有中间.

Option #4 could work, but you might run into limitations here. It's either the whole section is in a separate file or its all in the main file so there's no in-between.

选项 #5 看起来很有趣,但我没有使用它,所以我不能多说.

Option #5 looks interesting, but I haven't used it so I can't say much about it.

这篇关于使用 msdeploy & 构建一次并部署到多个环境视觉工作室 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:10