Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force MSBuild to compile for 32-bit mode?

I'm using MSBuild (via NAnt) to compile a bunch of VB.NET assemblies. Because these assemblies depend on COM Interop, I need to guarantee that they run in 32-bit mode on 64 bit OS's. I can get the executable assemblies to compile to 32-bit by changing the project in Visual Studio, but I'd really like to be able to force all of the executables to be compiled to 32 bit mode on the build server.

I've tried a number of command-line parameters to MSBuild with no luck:

  • /p:Platform=win32
  • /p:Platform=x86
  • /p:ProcessorArchitecture=x86

What am I doing wrong? Is there some reference to the properties that MSBuild uses when compiling VB projects?

like image 859
Eric Nicholson Avatar asked Jul 02 '09 14:07

Eric Nicholson


People also ask

Which is better 64-bit or 32 bit MSBuild?

Here's why it matters. Simply put, a 64-bit processor is more capable than a 32-bit processor because it can handle more data at once. A 64-bit processor can store more computational values, including memory addresses, which means it can access over 4 billion times the physical memory of a 32-bit processor.

What version of MSBuild does vs2022 use?

Visual Studio 2022 uses the 64-bit version of MSBuild for all builds.

What compiler does MSBuild use?

MSBuild uses csc.exe as its actual compiler but knows where to find assemblies, references etc based on your solution and project files (these files are actually xml files).

How do I run MSBuild manually?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.


2 Answers

According to MSDN, you're doing the right thing. Looks like /p:Platform=x86, but actually, maybe it's /p:PlatformTarget=x86.

Try to just invoke MSBuild directly with that parameter (make sure it's not an issue with your NAnt file. Look at the build output for the right build configuration (Debug / Release).

like image 76
Nader Shirazie Avatar answered Sep 26 '22 04:09

Nader Shirazie


If the assemblies themselves are always going to be 32 bit, why not add the setting to the .vbproj file? That will take MSBuild out of the equation.

Just add the following line to the initial PropertyGroup in the .vbproj file

<PlatformTarget>x86</PlatformTarget> 
like image 41
JaredPar Avatar answered Sep 22 '22 04:09

JaredPar