Also available at

Also available at my website http://tosh.me/ and on Twitter @toshafanasiev

Tuesday, 13 September 2011

MSBuild and .sln files

Microsoft's command line build tool MSBuild can consume Visual Studio solution files (.sln) even though they're not MSBuild project files (in contrast .csproj and .vbproj files are).
It does this by first converting the solution file to a valid MSBuild project then executing this project. If you're curious about what this project looks like, or want to tweak it for use in your automated build then you can get MSBuild to leave it on disk for you after a build.
Simply set the MSBuildEmitSolution environment variable to 1 before building and you'll find the newly created project file next to the original solution.
For example:

set MSBuildEmitSolution=1
msbuild <solution-name>.sln

This will leave a file called <solution-name>.sln.proj in the same directory - this is in the standard MSBuild XML format.

No comments:

Post a Comment