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”