简体   繁体   English

如何处理x86 vs x64包

[英]How to deal with x86 vs x64 packages

We use NuGet to manage our third party packages. 我们使用NuGet来管理我们的第三方软件包。

We also have to build both an x86 and x64 builds. 我们还必须构建x86x64版本。

We now have a dependency on a NuGet package ( zeromq ) that depends on a C dll and therefore has an x86 and x64 releases. 我们现在依赖于依赖于C dll的NuGet包( zeromq ),因此具有x86x64版本。

When searching in Nuget I only see two distinct projects (zeromq x64 and zeromq x86) and not one unified project. 在Nuget中搜索时,我只看到两个不同的项目(zeromq x64和zeromq x86),而不是一个统一的项目。

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). 我们在开发人员机器上的构建过程是在visual studio中选择适当的配置(即Debug / x86,Release x64等),因此我们使用的任何解决方案都必须适合visual studio GUI(即MSBuild soltuions不会'非常适合我们当前的工作流程)。

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? 约束的附录....如果我们不能在NuGet中自动执行此操作,是否有办法使用某种PowerShell预构建脚本执行此操作? 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? 即如果我们知道我们正在构建x86构建是否有一种方法来挂钩NuGet,以便它使用x86 packaes而不是x64包?

What is the proper way to manage NuGet Packages like this?? 管理这样的NuGet包的正确方法是什么?

Then you have two approaches, 那你有两种方法,

  • Create your own ZeroMQ fork and follow System.Data.SQLite.org to implement Native Library Pre-loading. 创建自己的ZeroMQ fork并按照System.Data.SQLite.org实现Native Library Pre-loading。 Then you can create a single NuGet package instead of two. 然后,您可以创建一个NuGet包,而不是两个。

  • Create two projects for your executable (the same source code, just two project files). 为您的可执行文件创建两个项目(相同的源代码,只有两个项目文件)。 One for x86 and the other for x64. 一个用于x86,另一个用于x64。 Add ZeroMQ's x86 package to your x86 one, while ZeroMQ's x64 to your x64. 将ZeroMQ的x86软件包添加到x86软件包中,将ZeroMQ的x64软件包添加到x64软件包中。 It is ugly, but IHMO it avoids conditioning in your project file (which can be easily broken by any bad MSBuild parser). 这很丑陋,但IHMO它避免了你的项目文件中的条件(任何错误的MSBuild解析器都可以轻松破解)。

I would think a good place to look would be http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference 我认为一个好看的地方是http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference

As far as I understand NuGet is really just Powershell for Build. 据我所知,NuGet实际上只是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. 我建议根据正在编译的当前平台(86/64)设置条件构建,然后将Get-Package过滤到您需要的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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