Web部署变得很棒:如果您使用的是XCopy,那么您做错了

I did three talks at Mix 10 this year, and I'm going to do blog posts for each one, sharing what I talked about and some code if it's useful.

我今年在Mix 10上做了三个演讲,我将为每个博客做一篇博客文章,分享我所讨论的内容以及一些有用的代码。

I did a talk on Deployment called "Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong."

我在部署方面做了一个演讲,名为“使Web部署变得很棒:如果您使用XCopy,那您做错了。”

You can download the talk here, or watch it online:

您可以在此处下载演讲或在线观看

VIDEO Download: MP4 Video, Windows Media Video, Windows Media Video (High)

视频下载: MP4视频 Windows Media视频 Windows Media视频(高)

I always try to sneak cooler titles into conferences if I can. It's better than "WEB101: Deploying Websites using Microsoft Visual Studio 2010's WebDeploy OneClick Publish Wizard Super Karate Monkey Death Car September CTP R2." Well, maybe not way better, but still.

如果可以的话,我总是尝试将一些比较酷的标题加入会议。 它比“ WEB101:使用Microsoft Visual Studio 2010的WebDeploy OneClick发布向导Super Karate Monkey Death Car September CTP R2部署网站要好。 好吧,也许没有更好的方法,但是仍然如此。

image

Here's an outline of what Deployment Related topics I tried to cover

这是我试图介绍的“部署相关主题”的概述

  • Web Packaging - Offline vs. Online

    Web打包-脱机与在线

    • From VS 2010

      从VS 2010开始
    • From IIS Manager

      从IIS管理器
  • Web.Config Transformation

    Web.Config转换

    • Transform Syntax

      转换语法
    • Locator Syntax

      定位符语法
    • Why not XSLT?

      为什么不使用XSLT?
  • Deploying

    部署中

    • Command Line

      命令行
    • What If Switch

      如果切换怎么办
    • From IIS

      从IIS
    • Content Sync

      内容同步
  • DB Deployment

    数据库部署

    • Scripting Source DB

      脚本源数据库
    • Adding custom SQL Scripts

      添加自定义SQL脚本
  • Download and Deployment of Open Source

    下载和部署开源

    • Web PI

      网络PI
    • App Gallery

      应用程式库
  • One Click Publish

    一键发布

    • Using Web Deploy (Ms Deploy) WMSVC

      使用Web部署(MS部署)WMSVC
    • Using Web Deploy (Ms Deploy) Remote Agent

      使用Web部署(MS部署)远程代理
    • Using InProc Web Deploy (Ms Deploy)

      使用InProc Web部署(女士部署)

Here's some cool highlights about WebDeployment in Visual Studio 2010. You can right-click on your web.config and click "Add Config Transforms."

这是有关Visual Studio 2010中WebDeployment的一些很酷的重点。您可以右键单击web.config,然后单击“添加配置转换”。

When you do this, you'll get a web.debug.config and a web.release.config. You can make a web.whatever.config if you like, as long as the name lines up with a configuration profile. These files are just the changes you want made, not a complete copy of your web.config.

执行此操作时,将获得一个web.debug.config和一个web.release.config。 您可以根据需要创建一个web.whatever.config,只要该名称与配置配置文件对齐即可。 这些文件只是您要进行的更改,而不是web.config的完整副本。

You might think you'd want to use XSLT to transform a web.config, but while they feels intuitively right it's actually very verbose.

您可能会认为您想使用XSLT转换web.config,但是尽管他们直观地感觉很对,但实际上非常冗长。

Here's two transforms, one using XSLT and the same one using the XML Document Transform syntax/namespace. As with all things there's multiple ways in XSLT to do this, but you get the general idea. XSLT is a generalized tree transformation language, while this deployment one is optimized for a specific subset of common scenarios. But, the cool part is that each XDT transform is a .NET plugin, so you can make your own.

这是两种转换,一种使用XSLT,另一种使用XML Document Transform语法/命名空间。 与所有事物一样,XSLT中有多种方法可以执行此操作,但是您已掌握了总体思路。 XSLT是一种通用的树转换语言,而此部署语言则针对常见方案的特定子集进行了优化。 但是,最酷的部分是每个XDT转换都是一个.NET插件,因此您可以自己制作。


   
   
NewSetting New Setting Value

Or the same thing via the deployment transform:

或通过部署转换进行相同的操作:


   
   
    
    
     
     
    
    
   
   

Now, to express this concretely, here's my new NerdDinner web.debug.config:

现在,为了具体表达这一点,这是我的新NerdDinner web.debug.config


   
   

and here's the web.release.config. Note that I update connectionStrings, change appSettings (in this case, Twitter library stuff), and change the system.web section, turning on customErrors and removing the debug attribute.

这是web.release.config 。 请注意,我更新了connectionStrings,更改了appSettings(在本例中为Twitter库的内容),并更改了system.web部分,打开customErrors并删除了debug属性。


   
   



xdt:Transform="SetAttributes" xdt:Locator="Match(key)" /> xdt:Transform="SetAttributes" xdt:Locator="Match(key)" /> xdt:Transform="Replace">

This is just config transforms, which is a small part of the whole deployment process. I also showed the packaging process and the package deployment that can happen with one-click from within Visual Studio, or can be initiated from IIS, or at the command-line from your Continuous Integration solution.

这只是配置转换,仅占整个部署过程的一小部分。 我还展示了打包过程和打包部署,这些打包过程和打包部署可以在Visual Studio中一键式进行,也可以从IIS启动,也可以在您的Continuous Integration解决方案的命令行中启动。

The WebDeploy packaging and deployment solution is also what the Web Platform Installer uses. It's all the same engine. This screenshot is me importing an open source application directly from a zip file. Note it's more than just what files to use, it's also setting ACLs (Access Control Lists, or permissions) and creating an IIS application. This just scratches the surface.

Web平台安装程序也使用WebDeploy打包和部署解决方案。 它们都是相同的引擎。 此屏幕快照是我直接从zip文件导入开源应用程序的过程。 请注意,不仅使用了什么文件,还设置了ACL(访问控制列表或权限)并创建了IIS应用程序。 这只是划伤表面。

 

Check out my talk, I hope it helps you out. There's more content in that 60 min talk than I could easily put in a single blog post.

查看我的演讲,希望对您有所帮助。 在60分钟的交谈中,有更多的内容比我在一篇博客文章中轻松发表的内容要多。

Related Links

相关链接

翻译自: https://www.hanselman.com/blog/web-deployment-made-awesome-if-youre-using-xcopy-youre-doing-it-wrong

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值