Generating an MSBUILD project file from a visual studio solution file and project files

msbuild

I know that I can pass MSBuild a VS solution file (.sln) and it will build the solution but somewhere in the back of my mind, I remember using a MSBuild command line switch that would take a solution file (and it's referenced project files) and generate a single MSBuild project file from them. However, I now can't find this switch!
Was this all a dream?

I see the /preprocess switch (short form /pp) but I don't think that this was it as this will include all of the imported files (including Microsoft.*.targets) and besides I can't seem to get this switch to work. I when I try the following command line, MSbuild generates the *.out file but its empty!

msbuild /target:rebuild /generate MSBuildCopyTargets.sln

Best Answer

The easiest way to do this is to run MSBuild from the command line, with an environment variable set:

  Set MSBuildEmitSolution=1

The output will be in the format SolutionName.metaproj

Related Topic