tags:

views:

1120

answers:

10

I simply wondered whether people thought it was worth learning to use the MSBuild syntax in order to customise the build process for a .net project, or whether it is really not worth it given the ease with which one can build a project using visual studio.

I am thinking in terms of nightly builds, etc., but then couldn't I use a scheduled event which uses the command-line build option built into VS? Are there superior tools out there?

+7  A: 

@kronoz
I would say YES.
The neat thing about MSBuild is that if you modify your csproj files to include custom build steps then those steps will happen from within VS or from MSBuild. Also if you ever have a build server you will not need to install full VS, only the SDK to build your projects.

Andrew Burns
+3  A: 

Well, MSBuild is built in, so if you are doing something simple, then yes, it is recommended.

But for something like nightly builds, I would suggest FinalBuilder.

See this question on Build/Configuration Management Tools.

Michael Pryor
+2  A: 

MSBuild is incredibly simple to use, you can use VS to manage the projects and solution files and just pass the SLN to MSBuild.

FlySwat
+3  A: 

It sounds like you are a single developer working on your own site. If this is the case, it's not necessary at all, but it is still a good idea for you to learn as a part of your professional experience.

Automated building of projects becomes more necessary as the number of developers working on a project increase. It is very easy for two developers to write incompatible code which will break when it is combined (imagine I'm calling a function foo(int x), and you change the signature to be foo(int x, int y): when we combine our code bases, the code will break.

These types of errors increase in complexity and hassle with the amount of time between integration builds. By setting up nightly builds, or even builds that occur every check-in, these problems are greatly reduced. This practice is pretty much industry standard across projects with multiple developers.

So now, to answer your question: this is a skill that will span across projects and companies. You should learn it to broaden your knowledge and skills as a developer, and to add an important line on your resume.

Travis
A: 

Building from the command line with MSBuild is relatively easy to learn. Start by opening a Visual Studio Command Prompt, and running msbuild /?. Just read through the help once and then decide later if you want to learn more details.

Writing project files is a bit more complicated. Most people don't need to learn it, because you can do most things in Visual Studio. However, it's also quite powerful for certain problems.

I have in the past used MSBuild as scripting language, combined with lots of custom tasks. MSBuild has fantastic logging support + built-in dependency management. However, it's not an easy language to learn. PowerShell is a much better choice.

Jay Bazuzi
A: 

I have a sub question to this question. I use C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com to do night building. What is the difference of MSBuild? Is it the same?

Daok
No, it's not really the same. Devenv.exe is the actual Visual Studio shell, so you are invoking a build through Visual Studio. Ultimately, the project files are MSBuild scripts themselves, so you end up running an MSBuild script.
Scott Dorman
MSBuild itself is an XML based scripting language that defines the actions that take place during a build.
Scott Dorman
+4  A: 

MSBuild is absolutely worth the time to learn. After the initial learning curve (which might be very steep actually) it becomes fairly easy to do the most common build automation steps.

  • building assemblies in RELEASE mode
  • signing assemblies with strong name
  • running unit tests
  • modifying xml files / Web.config-s on the fly
  • modifying the version number of the assemblies
  • validating FxCop / StyleCop etc...
  • automated deployment - create SQL databases, IIS websites, windows services etc...
Jivko Petiov
+1  A: 

In a scenario such as yours, where you do not already have a build system, then yes, MSBuild is absolutely worth it. Not only can you use it for a variety of pre-build and post-build tasks (see Jicko Petiov's answer), but you can also integrate it nicely into a continuous integration environment (such as CruiseControl).

One scenario where it might not be worth it is when you already have an automated/scripted build system in place. For example, I myself haven't taken the time with MSBuild because I've been using NAnt for this task since before MSBuild existed ...

John Rudy
+1  A: 

MSBuild is definitely worth learning for anyone and everyone writing .NET software. The reason a build server for .NET apps no longer requires Visual Studio to be installed (as Andrew Burns mentioned) is because MSBuild is part of the .NET Framework now.

Knowing MSBuild will give you significant flexibility in choosing what technologies you use to implement continuous integration. Because I took the time to learn MSBuild, I was able to change the CI system one of our teams was using from CruiseControl.NET to TeamCity without much difficulty. Those CI servers, or something like FinalBuilder (which I'm not familiar with), are better options for performing nightly builds than a scheduled task. Learning how to implement custom MSBuild tasks will give you even more flexibility in implementing custom builds. Jivko Petiov listed a number of tasks that MSBuild makes easier. In the case of database deployment and configuration, I've written scripts that do this in MSBuild, and it makes the development and testing process much easier.

If Visual Studio Team System is in your future, applications built using MSBuild will be much easier to move into that environment than those built via alternative means.

There are a lot of resources available to help you get started with MSBuild. I'd start with Inside the Microsoft Build Engine. One of the co-authors also has a ton of stuff on the web, including this site, and a project on CodePlex.

Scott A. Lawrence
A: 

@kronoz I would say YES. The neat thing about MSBuild is that if you modify your csproj files to include custom build steps then those steps will happen from within VS or from MSBuild. Also if you ever have a build server you will not need to install full VS, only the SDK to build your projects.

==> This is not entirely true. For example, building a setup project on a build server will require Visual studio to be installed!!

TMBAMF