Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing from "Any CPU" to "X64"

Previously, our software had to be created for both 32bit and 64bit Windows. Now, product management decided that we do not need to support 32bit Windows anymore (that's great with regard to third party SDKs and drivers).

In almost all of our some 200 projects, the DEBUG and RELEASE configurations have the "Platform target" of "Any CPU" only (only some wrappers of third party components are specialized). Of course, the software will run on 64bit systems with such settings. But compiling for 64bit only could allow for more compiler optimizations (or am I mistaken?), so I'd prefer to create 64bit executables.

As shown in How do I specify the platform for MSBuild? , there is no possibility to simply add a parameter to the msbuild command line, instead every project has to be changed...

What's the easiest way to do so? Or do I not need to care because there's no advantage in doing so?

Note: we use C# with Visual Studio Professional 2015 Version 14.0.25425.01 Update 3.

like image 770
Bernhard Hiller Avatar asked Nov 07 '22 13:11

Bernhard Hiller


1 Answers

there is no possibility to simply add a parameter to the msbuild command line, instead every project has to be changed... What's the easiest way to do so?

1.Just like what described in the link you mentioned above, you can easily create x64 Solution Platform for your current solution, make sure the create new project platforms option is enabled, and VS will help configure x64 platform for all the 200 projects.

2.But if your team has created the x64 solution platform before, but for now part of the projects are still Any CPU, if you don't want to change them one by one, you can click the Active Solution Platform dropdown and choose edit, remove the x64 solution platform. After that re-create new x64 solution platform will help create all x64 project platforms.

3.Also, in some situations you may need to apply some changes(Custom post-build event...) to all the projects in current solution, but it takes much time to manually do it. You may consider using Directory.Build.props.(Create a new one and place it in solution folder, all settings in it will be applied to the projects under the solution)

But since the property in xx.csproj will overwrite the same-name property from targets or props file, please avoid setting same-name property in this file.

As for if there's advantages in doing so.

You can check this list first, since your product manager decide to not support 32bit windows any more, if all your third-party sdks also support x64, you can feel free to switch to x64. But it may not make big performance differences whether your application build with x64 or Any CPU since it's always running in a 64bit windows. See the details from svick.

like image 198
LoLance Avatar answered Nov 13 '22 02:11

LoLance