简体   繁体   中英

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..

This scenario involves getting a developers 'local' version onto a 'development' server..

  1. Increment a developers local Web Applications Assembly version number
  2. Publish a developers local Web Application files somewhere
  3. .rar the publsihed files or folder into the format v[IncrementedAssemblyNumber].rar
  4. Copy the .rar to somewhere
  5. Backup (.rar) the existing live website folder (located elsewhere) in the format Pre_v[IncrementedAssemblyNumber].rar
  6. Move the backed up .rar to a /Backup folder.
  7. Overwrite the development web files with the published local web files

Should be simple for all those MSBUILD Gurus out there.

Like I said, answers or 'Good and applicable' links would be much appreciated.

Also i'm thinking of getting one of the MSbuild books. From what I can tell there are 2, possibly 3 contenders. I am not using TFS. Can anyone recommend a book for beginning 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 . For the deployment aspect you might want to take a look at the Microsoft Web Deployment Tool (MSDeploy) . It supports backing up websites (via .zip files) and updating. What I would do is to create an MSBuild file which will call into MSDeploy. Also PowerShell would be a good driver which calls MSDeploy. You can do the same tasks with MSBuild alone but it will be more difficult.

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 .

About books you can take a look at mine Inside the Microsoft Build Engine:Using MSBuild and Team Foundation Build . If you are not using TFS (and therefor Team Build) it's ok. The chapters on MSBuild ( 9 out of 12 ) are independent of TFS.

-- Edit: Assuming you're using .NET ...

Use NAnt, and use NAnt Contrib you call 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.

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.

  1. Install CruiseControl.Net (CC.NET)
  2. Wire up CC.Net to pull source-control files down to the CC.NET machine. Use a CC.NET task to do this. There is an SVN Task, TFS Task, etc.
  3. Write a msbuild definition file (.proj) to do most of the build logic. I put my file next to my .sln file...in source control.
  4. The .proj file will build your .sln.
  5. Add tasks in the .proj file to zip (rar) your build-artifacts (outputs of the build), publish, whatever you want to do.
  6. You can setup a few CC.NET "publish" tasks. 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. 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). The .proj file will transfer to to other CI tools. We went from CC.NET to TFS and because I had this forethought, the change was minimal. If I had used CC.NET specific tasks instead of .proj, the changeover would had been painful.

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

and

https://github.com/loresoft/msbuildtasks

have alot of extra functionality. Most msbuild needs have been coded up by somebody out there.

And if push comes to shove, you can always create a custom msbuild task. But that is rare these days.

There is the basic outline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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