Visual-studio – New projects not built when target platform is set explicitly

target-platformvisual studiovisual studio 2010visual-studio-2008

I create a new solution with one project, and then change the target platform from "Any CPU" to "x86". After this new projects added doesn't get built by default, and their target platform doesn't follow the global settings. Why?!

Looking at the configuration manager new projects added are not checked to "Build", and they get target platform "Any CPU" instead of the globally set x86. Why is this happening? I expect new projects too to get the globally set and defined x86 target platform.. Some things I've tried:

  • Toggle global platform back to Any CPU, and then to x86 again. No change..
  • Choosing platform explicitly for the new project. x86 is not available in the list, and when I say <New..> and try adding it I'm not allowed as ".. a solution platform with the same name already exists.".
  • On the build properties for the new project I can't change the platform in the Configuration section, but I can set "Platform target" to x86 in the General section. It is however not clear whether this actually makes a difference, and it wouldn't respond if I change the target platform globally later.

Initially I thought this was a problem from converting my solution from VS2008 to VS2010, but the problem applies both places. I.e. when I create a solution in VS2008 and just stay in VS2008 I still get the problem.

Best Answer

Yes, this is a very nearly breaking change in VS2010 and a bit of a mess. New solutions created in 2010 will have two configurations, "Debug|x86" and "Release|x86". Which is different from solutions created by previous versions, "Debug|Any CPU" and "Release|Any CPU" were the defaults.

When you then add an existing project created in a previous version to this VS2010 created solution, you'll get a nasty mixed bag. The platform combo now shows three options, "x86", "Any CPU" and "Mixed platforms". The latter will build all projects. What is also very confuzzling is that the configuration name actually doesn't directly affect the Platform Target setting.

It is fixable, you can search and replace "Any CPU" with "x86" in the .sln and .vcproj files with a text editor. Best approach perhaps is to stay out of trouble and let VS2010 convert a VS2008 solution instead of creating a new one. Yucky problem.