简体   繁体   English

用于部署过程的MSBuild文件

[英]MSBuild file for deployment process

I could do with some pointers, code examples or references that may help me do the following in an msbuild file to help speed up the deployment process.. 我可以使用一些指针,代码示例或参考来帮助我在msbuild文件中执行以下操作,以帮助加快部署过程。

This scenario involves getting a developers 'local' version onto a 'development' server.. 这种情况涉及将开发人员的“本地”版本安装到“开发”服务器上。

  1. Increment a developers local Web Applications Assembly version number 增加开发人员本地Web应用程序程序集版本号
  2. Publish a developers local Web Application files somewhere 在某个地方发布开发人员本地Web应用程序文件
  3. .rar the publsihed files or folder into the format v[IncrementedAssemblyNumber].rar .rar已发布文件或文件夹,格式为v [IncrementedAssemblyNumber] .rar
  4. Copy the .rar to somewhere 将.rar复制到某个地方
  5. Backup (.rar) the existing live website folder (located elsewhere) in the format Pre_v[IncrementedAssemblyNumber].rar 以Pre_v [IncrementedAssemblyNumber] .rar格式备份(.rar)现有的在线网站文件夹(位于其他位置)
  6. Move the backed up .rar to a /Backup folder. 将备份的.rar移至/ Backup文件夹。
  7. Overwrite the development web files with the published local web files 用发布的本地Web文件覆盖开发Web文件

Should be simple for all those MSBUILD Gurus out there. 对于所有那些MSBUILD Gurus来说应该很简单。

Like I said, answers or 'Good and applicable' links would be much appreciated. 就像我说的,答案或“良好且适用”的链接将不胜感激。

Also i'm thinking of getting one of the MSbuild books. 我也想得到一本MSbuild书籍。 From what I can tell there are 2, possibly 3 contenders. 据我所知,有2个竞争者。 I am not using TFS. 我没有使用TFS。 Can anyone recommend a book for beginning MSBUILD? 谁能推荐一本开始MSBUILD的书? Ideally from people that have read more than one book on the subject. 理想情况下,这些人应该阅读一本以上的书。

Cheers, 干杯,

-- Lee -李

I think for the build part you of course should use MSBuild . 我认为对于构建部分,您当然应该使用MSBuild For the deployment aspect you might want to take a look at the Microsoft Web Deployment Tool (MSDeploy) . 对于部署方面,您可能需要查看Microsoft Web部署工具(MSDeploy) It supports backing up websites (via .zip files) and updating. 它支持备份网站(通过.zip文件)和更新。 What I would do is to create an MSBuild file which will call into MSDeploy. 我要做的是创建一个MSBuild文件,该文件将调用MSDeploy。 Also PowerShell would be a good driver which calls MSDeploy. PowerShell也将是调用MSDeploy的良好驱动程序。 You can do the same tasks with MSBuild alone but it will be more difficult. 您可以单独使用MSBuild来完成相同的任务,但是会更加困难。

The aspect of your post that makes me wonder is your reference to "a developers local web ...". 您的帖子使我感到奇怪的是您对“开发人员本地网站...”的引用。 If it is possible you should have a build server which is responsible for creating all of your products which are going to non dev environments. 如果可能的话,您应该拥有一个构建服务器,该服务器负责创建将要用于非开发环境的所有产品。 As someone mentioned a good free CI server is CruiseControl.NET . 正如有人提到的那样,一个不错的免费CI服务器是CruiseControl.NET

About books you can take a look at mine Inside the Microsoft Build Engine:Using MSBuild and Team Foundation Build . 关于书籍,您可以在Microsoft Build Engine内部查看:使用MSBuild和Team Foundation Build If you are not using TFS (and therefor Team Build) it's ok. 如果您不使用TFS(以及团队建设),则可以。 The chapters on MSBuild ( 9 out of 12 ) are independent of TFS. MSBuild上的章节(12之9)与TFS无关。

-- Edit: Assuming you're using .NET ... -编辑:假设您正在使用.NET ...

Use NAnt, and use NAnt Contrib you call MSBuild. 使用NAnt,并使用NAnt Contrib(称为MSBuild)。 This will give you a basic system :) 这将为您提供一个基本系统:)

-- Edit -编辑

You should, of course, also get yourself a CI server, such as CruiseControl.NET, and hook it up to a source control system, like SVN, and then do your builds on that. 当然,您还应该获得CI服务器(例如CruiseControl.NET),并将其连接到源控制系统(例如SVN),然后在该服务器上进行构建。

Code should not go from a developer's box to a deployment server. 代码不应从开发人员的手中转到部署服务器。 It should go from source control via a CI (like CruiseControl.Net) to your deployment environment. 它应该从源控制通过CI(例如CruiseControl.Net)进入您的部署环境。

  1. Install CruiseControl.Net (CC.NET) 安装CruiseControl.Net(CC.NET)
  2. Wire up CC.Net to pull source-control files down to the CC.NET machine. 连接CC.Net,将源代码控制文件拉到CC.NET计算机上。 Use a CC.NET task to do this. 使用CC.NET任务执行此操作。 There is an SVN Task, TFS Task, etc. 有一个SVN任务,TFS任务等。
  3. Write a msbuild definition file (.proj) to do most of the build logic. 编写一个msbuild定义文件(.proj),以执行大多数构建逻辑。 I put my file next to my .sln file...in source control. 我将文件放在源控制中的.sln文件旁边。
  4. The .proj file will build your .sln. .proj文件将构建您的.sln。
  5. Add tasks in the .proj file to zip (rar) your build-artifacts (outputs of the build), publish, whatever you want to do. 在.proj文件中添加任务以压缩(rar)您的构建工件(构建的输出),发布,无论您想做什么。
  6. You can setup a few CC.NET "publish" tasks. 您可以设置一些CC.NET“发布”任务。 Most often the main one is to email a group of people that the build worked/failed. 通常,最主要的是向一群人发送电子邮件,告知他们构建成功/失败。

If you put the majority of your build logic in a .proj file, if you ever swap out from CC.NET to another CI tool, the amount of effort to do this is minimal. 如果将大多数构建逻辑放在.proj文件中,并且从CC.NET换成另一个CI工具,则这样做的工作量很小。 Using the above, you only need to swap the pulling of the source-control files and the handful of publish events (CC.NET proprietary tasks). 使用以上内容,您只需要交换源代码控制文件的提取和少数发布事件(CC.NET专有任务)。 The .proj file will transfer to to other CI tools. .proj文件将转移到其他CI工具。 We went from CC.NET to TFS and because I had this forethought, the change was minimal. 我们从CC.NET转到TFS,由于我有这种预见,因此更改很小。 If I had used CC.NET specific tasks instead of .proj, the changeover would had been painful. 如果我使用CC.NET特定任务而不是.proj,则转换将很痛苦。

http://mikefourie.github.io/MSBuildExtensionPack/ http://mikefourie.github.io/MSBuildExtensionPack/

and

https://github.com/loresoft/msbuildtasks https://github.com/loresoft/msbuildtasks

have alot of extra functionality. 有很多额外的功能。 Most msbuild needs have been coded up by somebody out there. 大多数msbuild需求已被某人编码。

And if push comes to shove, you can always create a custom msbuild task. 而且,如果一推再推,您总是可以创建一个自定义msbuild任务。 But that is rare these days. 但这几天很少见。

There is the basic outline. 有基本轮廓。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM