Max Young
Max Young

Reputation: 1662

What configuration and platform does msbuild use by default when building a solution file or project files

If I execute msbuild from the command line with my solution file or project file as input without setting configuration and platform how does msbuild determine which configuration and platform to use for each project in the solution or the single project file?

Upvotes: 12

Views: 4456

Answers (1)

radical
radical

Reputation: 4424

In case of solution files - both msbuild and xbuild try to find Debug config and Mixed platforms platform, but if that doesn't exist then it falls back to the first one that it can find under SolutionConfigurationPlatforms in the .sln file. Keep in mind that this is just solution level config/platform, and it uses the mapping in ProjectConfigurationPlatforms in the .sln file to determine the config/platform to use for the project.

In case of project files, the *proj files usually have the default Configuration and Platform specified. But if even that is missing then the Microsoft.Common.*targets file chooses Debug|AnyCPU as the default.

Update: default specification in the csproj might look like this:

  <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
     ...

It's essentially saying "if $(Configuration) is unspecified, then set it to Debug", and similar for Platform.

Upvotes: 18

Related Questions