使用msdeploy&进行一次构建并部署到多个环境中Visual Studio 2012 [英] Build once and deploy to multiple environments with msdeploy & Visual Studio 2012

查看:97
本文介绍了使用msdeploy&进行一次构建并部署到多个环境中Visual Studio 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. 使用文件或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. See Deploying 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&进行一次构建并部署到多个环境中Visual Studio 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆