How can I change the Build.Platform property in a Visual Studio project?
Asked Answered
C

1

6

One of the many projects in a very large solution somehow became set to Build Platform == Active (x86). I want it to match all of the other projects ("Any CPU").

I successfully changed the Platform target dropdown from "Active (x86)" to "Any CPU", but the Platform dropdown has "Active (x86)" as the only option:

enter image description here

I don't know how this project got "out of sync" with the others as to this setting to begin with, and more importantly how to get it back in line with the others...

UPDATE

I think the problem may have been that my VS install was set to VB instead of C# (it was done by IT, and most of the cats here are VB developers).

This: http://go4answers.webhost4life.com/Example/buildsolution-configuration-dropdown-188435.aspx mentions Tools | Settings, but I have no such menu item.

I did select the option to reset settings to original, and the "Settings Reset in Progress" dialog has been churning away for nigh on to half an hour now, with VS "(Not Responding")

UPDATE 2

Now I'm having the opposite problem with a Windows CE project - I need it to be "x86" and it refuses to change to that from "Any CPU".

The reason why I want to change this setting is because when trying to run this app on a handheld device I'm getting the "Can’t find P/Invoke DLL sqlcemeNN.dll" err msg.

According to this: "If your machine is a 64-bit box, you might have been got trapped into default target platform 'Any CPU' trap, please set the target platform as 'x86'. Need more details, please visit ErikEJ's blog post."

My machine is 64-bit, and I did read the blog post referenced

...but I have no "x86" option in my Confriguration Manager's "Active Solution Platform" dropdown. "Any CPU" is the only option it gives me...

I was able to somehow force the "Active Solution Platform" dropdown to say "x86" after typing that in, but I don't think it really changed anything. In the grid, the only option is "Any CPU". Selecting "Edit..." (there is no "New...") from the "Project" column just shows "Any CPU" in the list, a greyed-out "Remove" button, and a Close button ("greyedoutprojectplatforms.png")

So what I tried is I changed every instance of "Any CPU" in the project's .csproj file to "x86" and STILL it says "Any CPU" in Project > Properties > Build > Platform Target!

Culinarian answered 12/7, 2013 at 18:45 Comment(5)
When you edit the .csproj file in a text editor what do you see?Duaneduarchy
Right now all I'm seeing (it's been over an hour now) is the hourglass/Not Responding message after setting the settings back to their original settings (or trying to).Culinarian
I finally gave the Rip Van Winklesque instance of VS the three-fingered-salute, and (see my comment in reply to Giorgio below for more of the ongoing saga).Culinarian
Each of the 31 projects has a .csproj file. Is there an analgous file for the entire solution?Culinarian
I viewed the .sln file as text and didn't see anything "interesting". ISTM I've been spending far too much time lately "taming the beast" and not nearly enough time coding. I'm in this to create, not to be a configuration mechanic, fine-tuning obscure and opaque arcana deep in the dark and dank recesses of the submarine layer of the coding tools. IOW: argghhhh!!!Culinarian
E
5

Try adding a new build configuration to your project from the solution file (right click it on Visual Studio, properties then go to Configuration Manager.

Otherwise you can manually edit the project file (open the *.csproj with notepad) and add back the rule for AnyCpu http://msdn.microsoft.com/en-us/library/ms734788(v=vs.85).aspx.

It is likely that if you're working in a team with source control and continuous integration, this has been changed by someone to satisfy a requirement on the build server. Probably the cleanest thing to do is add a custom build configuration for your project and use that one on your solution.

Episodic answered 12/7, 2013 at 18:59 Comment(1)
Okay, I changed the two recalcitrant projects from "x86" to "Any CPU" by selecting "New" from the Platform dropdown and then setting "New platform" to "Any CPU" and "Copy settings from" to "empty" and making sure the "Create new solution platforms" checkbox was unselected. Now all Platforms (for all 31 projects) are set to "Any CPU".Culinarian

© 2022 - 2024 — McMap. All rights reserved.