Click here to Skip to main content
15,881,455 members
Articles / MSBuild
Tip/Trick

Creating MSBuild projects from .sln files.

Rate me:
Please Sign up or sign in to vote.
4.92/5 (16 votes)
6 Apr 2011CPOL 93.7K   25   10
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)


Written By
CEO
United Kingdom United Kingdom
A developer for over 30 years, I've been lucky enough to write articles and applications for Code Project as well as the Intel Ultimate Coder - Going Perceptual challenge. I live in the North East of England with 2 wonderful daughters and a wonderful wife.

I am not the Stig, but I do wish I had Lotus Tuned Suspension.

Comments and Discussions

 
QuestionWhat makes an msbuild.proj file more proper than the solution file? Pin
RS785776623-Jun-16 1:13
RS785776623-Jun-16 1:13 
AnswerRe: What makes an msbuild.proj file more proper than the solution file? Pin
Pete O'Hanlon23-Jun-16 2:12
mvePete O'Hanlon23-Jun-16 2:12 
QuestionWorkaround/Update for VS 2013 Pin
mrchief_200010-Dec-14 9:56
mrchief_200010-Dec-14 9:56 
QuestionNice! Pin
drhender18-Nov-13 6:40
drhender18-Nov-13 6:40 
QuestionIn Application Pin
Éverton França18-Jul-13 9:15
Éverton França18-Jul-13 9:15 
AnswerRe: In Application Pin
Pete O'Hanlon18-Jul-13 9:23
mvePete O'Hanlon18-Jul-13 9:23 
GeneralUseful! Pin
Brisingr Aerowing29-Mar-13 14:18
professionalBrisingr Aerowing29-Mar-13 14:18 
QuestionNice one! Pin
Xandip27-Sep-12 21:46
Xandip27-Sep-12 21:46 
AnswerRe: Nice one! Pin
Member 947095929-Sep-12 9:39
Member 947095929-Sep-12 9:39 
GeneralClean and Simple Pin
MackZero29-Aug-12 10:36
MackZero29-Aug-12 10:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.