user2421167
user2421167

Reputation:

MSBuild to build all defined configurations

I'm looking for a way to call MSBuild with all possible configurations/platforms defined in the solution file.

I've looked here: Using MSBuild to Build Multiple Configurations

which requires explicit knowledge of the configurations, as you must enumerate them on the command line,

and here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/066c9dbf-d191-4b8c-8ee1-b9709b56c500/msbuild-for-visual-studio-2010-build-all-configurations-of-a-vcxproj-file?forum=msbuild

which leads to another page that suggests defining another project file to encapsulate the msbuild calls. Unfortunately, it too requires explicit knowledge of the configurations.

So then, is there any way to obtain through the command line, the list of configurations/platforms availalbe to a given project? (It must be the same list that is modified in Visual Studio. ie: adding/removing a configuration in Visual Studio, saving, exiting, and getting the list, would reflect the changes.)

Parsing the solution file as XML is not an option, as it wouldn't be stable if Microsoft decided to change how it is formatted.

Upvotes: 0

Views: 2002

Answers (1)

Ilya Kozhevnikov
Ilya Kozhevnikov

Reputation: 10432

You can't parse a solution as XML it's not a markup file without having MSBuild emitting a meta project first. I recommend you play the odds and be pragmatic, read the .sln as a text file and RegEx it on SolutionConfigurationPlatforms pairs, then build the ItemGroup and batch it. If you are truly utterly paranoid about Microsoft completely reengineering the solution file syntax then look inside Microsoft.Build.Construction and/or .Evaluation, the internal SolutionParser, or Roslyn or even Mono since if the syntax changes then those parsers and loaders would be updated accordingly and in case of Microsoft.Build and Roslyn -- simultaneously.

Upvotes: 1

Related Questions