如何强制 MSBuild 编译为 32 位模式? [英] How do I force MSBuild to compile for 32-bit mode?

查看:31
本文介绍了如何强制 MSBuild 编译为 32 位模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MSBuild(通过 NAnt)来编译一堆 VB.NET 程序集.因为这些程序集依赖于 COM Interop,所以我需要保证它们在 64 位操作系统上以 32 位模式运行.我可以通过在 Visual Studio 中更改项目来将可执行程序集编译为 32 位,但我真的希望能够在构建服务器上强制将所有可执行文件编译为 32 位模式.

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.

我已经尝试了许多 MSBuild 的命令行参数,但都没有成功:

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

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

我做错了什么?编译VB项目时MSBuild使用的属性有没有参考?

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

推荐答案

如果程序集本身总是 32 位,为什么不将设置添加到 .vbproj 文件中?这将使 MSBuild 脱离等式.

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.

只需将以下行添加到 .vbproj 文件中的初始 PropertyGroup

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

<PlatformTarget>x86</PlatformTarget>

这篇关于如何强制 MSBuild 编译为 32 位模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆