65.9K
CodeProject is changing. Read more.
Home

Creating MSBuild projects from .sln files.

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.92/5 (16 votes)

Apr 6, 2011

CPOL
viewsIcon

95460

If you want to create MSBuild files, and only have Visual Studio solutions, take heart - there is a trick that will help you out.

I recently had a need to create an MSBuild file for a complex (multi-project) solution in VS2010. By default .sln files are not in msbuild format, but they can be called from MSBuild - while I could have done this, I didn't want to - I wanted a proper MSBuild solution. Fortunately, there is a way to convert the .sln file into an MSBuild .proj file. Open up a Visual Studio command prompt and type in the following:
set MSBuildEmitSolution=1
msbuild <<your project>>.sln 
That's it. If your solution builds successfully, an addition MSBuild .proj file is created (this is the file that MSBuild creates internally to process .sln files). It's that simple.