Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 743
B. Clay Shannon-B. Crow Raven Avatar asked Jul 12 '13 18:07

B. Clay Shannon-B. Crow Raven


People also ask

How do I change the build platform in Visual Studio?

To change the platform toolsetIn the properties page, select Platform Toolset and then select the toolset you want from the drop-down list. For example, if you've installed the Visual Studio 2010 toolset, select Visual Studio 2010 (v100) to use it for your project.

How do I change the platform target in Visual Studio?

To configure a project to target a different platformOn the menu bar, choose Build > Configuration Manager. In the Active solution platform list, choose a platform for the solution to target, and then choose the Close button.

How do I change a platform target from x86 to a CPU?

Select x86 in the Copy settings from drop-down list box. Click OK. In the Configuration Manager dialog, be sure the box in the Build column is checked for all projects in the solution. Click Close.

How do I get build options in Visual Studio?

If you want to build multiple configurations and platforms in one action, you can use the Build > Batch Build option in Visual Studio. To access this feature, press Ctrl+Q to open the search box, and enter Batch build .


1 Answers

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.

like image 194
Giorgio Minardi Avatar answered Sep 28 '22 04:09

Giorgio Minardi