Is there a good tutorial on MSBuild scripts? [closed]
Asked Answered
H

9

99

I'm working on a web application project, and I need to create a build script; a build script that I can trigger from my cruisecontrol server. Since nant has not been maintained for ages, I figure that MSBuild is the way to go.

I need the build script to be able to

  • Compile all assemblies
  • Execute unit tests
  • Run NCover analysis on the unit tests
  • Deploy the database (depending on parameters). This is really executing a tool since I will end up writing my own tool to deploy the database. But the execution of the tool should be conditional based on some command line parameter.
  • Deliver unit tests and coverage results in a format that cruisecontrol can read and understand.

I assume that MSBuild will allow me to do all these things. But I don't know where to start. Does anybody know of a good tutorial to get me started with my build script?

Helbonnah answered 25/8, 2009 at 6:50 Comment(1)
@Preet Sangha: I didnt find that to be the case - you can waste a lot of time half understanding the syntax as you work from cookbooks. I thing its a very important question and I hope this quesiton becomes a good place to point people.Halves
N
40

This was my first tutorial. Very easy to understand and follow:

https://codingcockerel.wordpress.com/2008/04/15/automating-the-build-with-msbuild/

Naara answered 26/8, 2009 at 17:44 Comment(3)
Having no prior experience with MSBuild I found this tutorial to be very easy to understand. The demo code worked in VS2008 without hassle.Inexpedient
this link is failing (Feb 17 2016). 403 Forbidden...Touchhole
Linked is fixed after the edit made by STW on Aug 1 2016.Naara
C
13

Start here : http://brennan.offwhite.net/blog/2006/11/29/msbuild-basics-1of7/

Callboard answered 25/8, 2009 at 7:51 Comment(4)
this link is failing as of Feb 16 2010. So to is the blog brennan.offwhite.net/blog which comes up in google.Inexpedient
just found one on the google cache 74.125.155.132/search?q=cache:http://brennan.offwhite.net/blog/…Callboard
This tutorial is kind of confusing and poorly structured.Physicochemical
The link worked for me (Aug-2010)Epley
H
9

I wasted a lot of time before buying the Hashimi MSBuild book, fantastic -- I concur with this review by Steven St Jean.

In addition to an excellent all-round introduction to MSBuild scripting, it has a cookbook section on doing typical build automation thigns like build numbers etc. Obviously the last TeamBuild section will not be directly relevant for you, but a lot of the topics are generic across all CI tools.

UPDATE: The 2nd ed keeps up the trend, adding a must-have section re WebDeploy

Halves answered 27/8, 2009 at 7:22 Comment(2)
Follow-up: Both authors have been swallowed by the Borg right now [from which one may or may not wish to infer information pertaining to the quality of the book]Halves
This is a great reference book covering almost everything you need to know to do really sophisticated build automation with MSBuild.Muniz
M
9

There is a "Getting Started with MSBuild" blog post on the the Visual Studio Blog which gives a good overview on how MSBuild is hooked up with Visual studio. It's fairly recent (25.02.2010) and uses Visual Studio 2010 and the accompanying MSBuild v4.0.

There is not much code there though.

It wasn't until reading this blog that I understood that the *.csproj files themselves are MSBuild files. And also, that the Build, Clean, Rebuild and Publish command in the project context menu actually are MSBuild "targets".

Mildredmildrid answered 29/6, 2010 at 11:45 Comment(0)
S
8

I wrote this a couple of years ago and try to keep it up to date with new MSBuild features:

http://thomasardal.com/msbuild-tutorial/

Subatomic answered 25/9, 2012 at 15:38 Comment(0)
H
5

I found this MSBuild tutorial by Patrick Smacchia to be very informative (though I read it as a non-beginner)

Also Best Practices for Creating Reusable Builds, Part 1 from MSDN Magazine by Sayed Ibrahim Hashimi and part 2

(And I +1'd the Brennan tutorial)

Halves answered 27/8, 2009 at 7:24 Comment(0)
E
5

Check this on MSDN How to: Write a Simple MSBuild Project .

Its good article and had helped me to start.

Here is the pdf of print version of the same .

Eth answered 24/2, 2010 at 10:29 Comment(0)
S
1

I find this book pretty handy: http://www.amazon.com/Deploying-NET-Applications-Learning-ClickOnce/dp/1590596528/

Saporific answered 25/8, 2009 at 16:45 Comment(0)
A
1

I'm looking for info on this subject myself too.

This is a nice article, Versioning Builds with TFS and MSBuild.

I posted a Stackoverflow answer here to a related question, where I also mention this great episode on DnrTV, Sayed Hashimi on MS Build.

Authenticate answered 27/8, 2009 at 7:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.