C# 针对 x86 和 x64 的设置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/753412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setup targeting both x86 and x64?
提问by Malfist
I have a program that requires both x64 and x86 dlls (it figures out which ones it needs at run time), but when trying to create a setup, it complains:
我有一个程序需要 x64 和 x86 dll(它在运行时确定需要哪些),但是在尝试创建设置时,它抱怨:
File AlphaVSS.WinXP.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'
File AlphaVSS.Win2003.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'
File AlphaVSS.Win2008.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'
文件AlphaVSS.WinXP.x64.dll“瞄准‘AMD64’是不是个项目的目标平台兼容‘86’
文件AlphaVSS.Win2003.x64.dll”定位,‘AMD64’是不是个项目的目标平台‘x86的’兼容
文件AlphaVSS .Win2008.x64.dll' 针对'AMD64' 与项目的目标平台'x86' 不兼容
How can I make my setup target both platforms like my program does?
如何让我的设置像我的程序一样针对两个平台?
采纳答案by Magnus Johansson
The MSI created by the setup project (in Visual Studio) can only target one platform at a time. Your option is to either make 2 MSI's, merge them together and make a custom setup boot strapper that choose between the two. There are some 3rd party products,like Advanced Installerfor example, that can do this for you.
安装项目(在 Visual Studio 中)创建的 MSI 一次只能针对一个平台。您的选择是制作 2 个 MSI,将它们合并在一起并制作一个自定义设置引导程序,在两者之间进行选择。有一些 3rd 方产品,例如Advanced Installer,可以为您执行此操作。
回答by Joel Coehoorn
.Net has an "Any CPU" option. It's tempting to think of it as more of a "generic" option that's going to only use the lesser x86 features, but really it lets the JIT compiler on each machine pick the appropriate cpu type for that machine.
.Net 有一个“Any CPU”选项。人们很容易将其视为仅使用较少的 x86 功能的“通用”选项,但实际上它让每台机器上的 JIT 编译器为该机器选择合适的 cpu 类型。
The only time you shouldn't use it is if you know you have dependencies or requirements that aren't good for one architecture or the other. For example: you know you need a lotof ram, you have a dependancy on a 32-bit native dll, or you want to pre-compile the app.
唯一不应该使用它的情况是,如果您知道自己的依赖项或要求对一种架构或另一种架构不利。例如:您知道您需要大量内存,您依赖于 32 位本机 dll,或者您想要预编译应用程序。
There's a danger here because you have a platform-specific dll dependancy. But you have dlls for both types and it sounds like you know how to pick the right one at runtime. So will the 'Any CPU' option work for you?
这里存在危险,因为您有特定于平台的 dll 依赖项。但是您有两种类型的 dll,而且您似乎知道如何在运行时选择正确的 dll。那么“Any CPU”选项对您有用吗?
回答by Daren Thomas
I ran into this too and wrote a blog postabout my solution:
- deflate the file using deflate.exe, naming it with a different extension (e.g. .x64)
- add it to your main project as a content file
- add a custom action project to your solution
- add the custom action to the setup projects "Install" custom actions
- inflate the file inside the custom actions Install method using
- System.IO.Compression.DeflateStream (see code above)
- do a little dance around your desk, down the hall, and past as many coworkers as you care to annoy :)
- 使用 deflate.exe 压缩文件,使用不同的扩展名(例如 .x64)命名它
- 将其作为内容文件添加到您的主项目中
- 将自定义操作项目添加到您的解决方案
- 将自定义操作添加到安装项目“安装”自定义操作
- 使用自定义操作安装方法中的文件膨胀
- System.IO.Compression.DeflateStream(见上面的代码)
- 绕着你的办公桌跳一小段舞,穿过大厅,穿过你想惹恼的尽可能多的同事:)
The deflate.exe
file can be downloaded from its repositoryon google code.
该deflate.exe
文件可以从其在谷歌代码的存储库中下载。
回答by MOHAMED SAKR
- Open a deployment project.
- In the Solution Explorer, select the deployment project.
- In the Properties window, select the TargetPlatform property.
- Choose either Itanium for an Intel Itanium 64-bit platform, or x64 for any other 64-bit platform (such as AMD64 and EM64T instruction sets).
- At installation time, an error will be raised and installation will be halted if the target computer is not compatible with the specified platform.
- 打开部署项目。
- 在解决方案资源管理器中,选择部署项目。
- 在“属性”窗口中,选择 TargetPlatform 属性。
- 为 Intel Itanium 64 位平台选择 Itanium,或为任何其他 64 位平台(如 AMD64 和 EM64T 指令集)选择 x64。
- 安装时,如果目标计算机与指定平台不兼容,将引发错误并暂停安装。