MSBuild and Solution Files

30Nov06

I find the vast majority of documentation on using MSBuild to compile Visual Studio solutions is way too complicated.  MSBuild is very powerful, in that you can customize a lot of what is going on in the build process.  However, sometimes you just want to do a simple compile of a visual studio solution in your msbuild script, without having to worry about reconstructing references and other such nonsense.  It’s a one-liner task:

    <MSBuild Projects=MySolution.sln           Properties=Configuration=Debug ContinueOnError=false />
 

I did a lot of research on MSBuild in the last month, and it was amazing just how long it took me to realise that MSBuild will parse .sln files for you.  I guess it was just too obvious (in other words, it says it right there if you go msbuild /? ).

You could do this from the command line as well instead of using devenv.exe: 
msbuild mysolution.sln /p:Configuration=Release

Solution files are not proper MSBuild scripts (unlike vbproj and csproj files), but MSBuild can still work with them. I recommend this excellent article by Sayed Ibrahim Hashimi if you want to go a bit deeper into using the solution file in MSBuild.  He talks about generating a proper .proj file from a solution file with a custom task, and then working with that for any other customization you require in your build process.

0 Responses to “MSBuild and Solution Files”


  1. No Comments

Leave a Reply


Comment guidelines: No spamming, no profanity, and no flaming. Inappropriate comments will be deleted outright.

Quote selected text




 

About

My name is Dylan Marks. I'm a programmer and tech consultant focused on web application development, typically using ASP.NET, javascript and web standards-based technologies. I hope to share some of the useful tips and tricks I've discovered while making things work. I live in Edmonton, Alberta, Canada, working remotely for clients across North America. Email Me.