Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add x64 (or Any CPU) as a build option in Visual Studio 2010 (from console application to class library)

Initially, I created a console application using Mass Transit as my service bus. Recently, I switched to NServiceBus, which doesn't require you to make a console application, but a class library instead. In the project properties, I simply switched the setting that changes it from a console application to a library, but the constraint that you can only build it for x86 is still in effect.

I can't change the build type to Any CPU now that it is a console application, which should now be valid. Is there any way to completely change my application to a class library so that I can run the build Any CPU option? Do I need to create a new project, copy files into it and continue that way? Or is it as simple as changing something in the project (.proj) file?

The Stack Overflow question Missing Debug|Any CPU build configuration for projects and defaulting to Debug|x86 on Windows x64 gives more context around this issue of x86 only for console applications.

like image 986
Ryan Hayes Avatar asked Nov 30 '11 21:11

Ryan Hayes


People also ask

How do I create a 64-bit project in Visual Studio?

Choose the Configuration Manager button to open the Configuration Manager dialog box. In the Active Solution Platform drop-down list, select the <New...> option to open the New Solution Platform dialog box. In the Type or select the new platform drop-down list, select a 64-bit target platform.

How do I get build options in Visual Studio?

For example, Debug and x86. Other defined configurations and platforms are not built. 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 .

How do I change from x86 to x64 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 run Visual Studio in 64-bit mode?

From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit process.


1 Answers

You just need to add a configuration for Any CPU in the configuration manager.

1) Right-click the solution and select Properties

2) Select Configuration Properties, then click Configuration Manager...

3) Change the Active Solution platform to Any CPU. If there is no Any CPU platform, skip to #4.

4) Click the arrow in the combo box under the Platform column for your class library, and select New...

5) Make sure "Any CPU" is selected under New Platform. If there was no Any CPU solution platform in step 3, then make sure the "Create new solutions platform" checkbox is checked. Then click OK.

6) Check the checkbox in the "Build" column for your class library

7) Close out of the Configuration Manager, and open the properties for your class library

8) Select Any CPU for Platform, then select Any CPU for Platform target, and save.

(Step 8 may or may not be necessary, depending on what has been done with the configurations previously.)

like image 102
Gerald Avatar answered Sep 28 '22 06:09

Gerald