msbuild for 64-bit “Any CPU” platform

3 02 2011

Today I solved a problem with one of the executables of a .NET application not starting on Win7 x64. The application ran fine on both WinXP (32-bit) and Win7 (64-bit) when built from within VS2010, no matter if it was built on a WinXP (32-bit) or Win7 (64-bit) machine. But it failed when built on our hudson build server which is running on the WinXP (32-bit) machine.

As it turned out, two of the application’s assemblies where compiled for the x86 platform when the application was built through hudson. The following msbuild command line argument was used to build the solution:

/p:Configuration=Release

Digging inside the solution’s .vcproj files revealed that the project files for the two assemblies in question erroneously contained Release|x86 and Debug|x86 configurations in addition to the Release|AnyCPU and Debug|AnyCPU configurations.

Obviously msbuild decided to build one of the x86 configurations of these assemblies as no explicit platform target was specified on the command line. This was surprising as the project file for these assemblies defaulted to the AnyCPU platform. This looks like a bug in msbuild to me.

The problem could be solved by explicitly specifying the target platform through an additional msbuild command line argument:

/p:Configuration=Release /p:Platform="Any CPU"

Note that the value of the Platform property has to be “Any CPU” (with a blank inside) even through it’s called “AnyCPU” (with no blank) inside the .vcproj file!

Additionally I eliminated the Release|x86 and Debug|x86 configurations from the conflicting assemblies to avoid running into the same pitfall again.


Aktionen

Information

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s




%d Bloggern gefällt das: