programmatically set build configuration in Visual Studio solution
I have created a tool that generates a solution containing multiple projects. The problem is when I open this solution up in VS the configuration build option is not set (i.e if you build the solution the projects don't get built - they are skipped). The user has to go in and manually check the check boxes in the configuration dialog in order to have these projects build with the solut开发者_运维知识库ion.
I am unclear as to how to automatically set this value. Where can this be set?
In your solution file, you need to add a section something like
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{Project_Guid}.Debug|x64.Build.0 = Debug|x64
EndGlobalSection
Where Project_Guid
is the unique ID for your project ( not the Project Type ID ). This tells the solution which Project configurations to build for each Solution configuration. In this case, build the Project Debug|x64 configuration for the Solution's Debug|x64 configuration.
Thanks Andrew. It turns out my guids where all lowercase (generated by Guid.NewGuid()). This appears to confuse VS. Changing the Guid generation to Guid.NewGuid().ToString().ToUpper() fixes the problem
精彩评论