Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / MSBuild

Creating MSBuild projects from .sln files.

4.92/5 (16 votes)
6 Apr 2011CPOL 95.5K  
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)