简体   繁体   中英

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??

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).

I would think a good place to look would be http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference

As far as I understand NuGet is really just Powershell for Build. I would suggest setting up a conditional build based on the current platform being compiled (86/64) and then filter the Get-Package to the version you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM