Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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
like image 442
PMBottas Avatar asked Mar 08 '11 20:03

PMBottas


People also ask

What is the difference between MSBuild and Visual Studio build?

Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control. Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project.

Does Visual Studio include MSBuild?

If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin.

How do I create a SLN file in MSBuild?

At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute. Specify the target after the -target: switch in the format <ProjectName>:<TargetName>.


Video Answer


1 Answers

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

like image 83
Ritch Melton Avatar answered Oct 04 '22 02:10

Ritch Melton