Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with x86 vs x64 packages

We use NuGet to manage our third party packages.

We also have to build both an x86 and x64 builds.

We now have a dependency on a NuGet package (zeromq) that depends on a C dll and therefore has an x86 and x64 releases.

When searching in Nuget I only see two distinct projects (zeromq x64 and zeromq x86) and not one unified project.

Constraint

Our build process on the developers machines is to select the appropriate configuration(ie Debug/x86, Release x64, etc) in visual studio and build so any solution we use would have to fit into the visual studio GUI( ie MSBuild soltuions wouldn't' really fit our current workflow).

EDIT

Addendum to the constraint....If we can't do this automatically within NuGet, is there a way to do this with some sort of powershell prebuild script? ie if we know we are building the x86 build is there a way to hook NuGet so that it uses the x86 packaes instead of the x64 packages?

What is the proper way to manage NuGet Packages like this??

like image 594
chollida Avatar asked Aug 26 '13 14:08

chollida


People also ask

How do I choose between x86 and x64?

In the right pane, look at the System Type entry. For a 32-bit version operating system, it will say X86-based PC. For a 64-bit version, you'll see X64-based PC.

Can I run x86 programs on x64?

Yes, of course. Most programs are still 32 bit and run fine on 64-bit Windows systems. Those programs are machine language, which has a one-to-one mapping with assembly (and can be easily disassembled into x86 assembly code).

Should I target x86 or x64?

So, target x86 or x64. Since x86 apps run on both x64 and x86 systems, the most compatible choice is to build x86. If you MUST build a 64 bit solution, you'll need to target x64 and use our x64 dlls.

Do I need to download x64 or x86?

If you use a CPU that supports x64, you should always install a x64 version of windows. A x64 Windows can run both 32 and 64 bit versions of software. But, a x86 can only run 32 bit software. You should download the x86 JDK.


1 Answers

Then you have two approaches,

  • Create your own ZeroMQ fork and follow System.Data.SQLite.org to implement Native Library Pre-loading. Then you can create a single NuGet package instead of two.

  • Create two projects for your executable (the same source code, just two project files). One for x86 and the other for x64. Add ZeroMQ's x86 package to your x86 one, while ZeroMQ's x64 to your x64. It is ugly, but IHMO it avoids conditioning in your project file (which can be easily broken by any bad MSBuild parser).

like image 106
Lex Li Avatar answered Sep 18 '22 19:09

Lex Li