views:

392

answers:

1

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.

+1  A: 

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.

Hans Passant
Thanks! Will try seach+replace in .sln, but doesn't sound ideal :-/ Note that I did actually let VS2010 convert my VS2008 solution, and I get the problem when I add new projects - not existing VS2008 projects. Also; I get this when working only with VS2008 - no upgrade, no nothing - just changing target platform and adding new clean projects. So it doesn't (just) seem to be a VS2010 thing.
stiank81
Seems like I'm able to fix it by modifying the solution and project files. Can't replace all "Any CPU" with "x86", but it was rather straight forward to figure out what should be done. And this actually make it respond to changes done to the global setting later. Great! :-)
stiank81