根据编译常量更改 EXE 名称
我有一个 VB.NET 2010 项目(编译为 x86、.NET 2.0 运行时),我想将其编译为两个单独的 EXE - 一个“精简”版本和一个“完整”版本。
不幸的是,我无法创建两个单独的项目,因为它使用 Adobe Reader COM 控件 - 并且在两个项目之间使用该控件共享表单似乎会混淆 IDE(我认为与 COM Interop 有关 - 如果有人知道如何共享表单)托管 adobe reader 控件,这也可以解决我的问题)。
我找到了这个线程: 根据条件编译更改 exe 的名称符号 但是我没有任何 MSBuild 经验,因此我需要更明确的说明。
在“我的项目>编译”选项卡上有一个“构建事件...”按钮。我想知道是否有人知道如何设置条件编译常量并使用它来确定 EXE 名称(或在构建后更改它)。
如果一切都失败了,我想我可以手动重命名 EXE,但我更希望它是自动化的。
I have a project in VB.NET 2010 (compiling to x86, .NET 2.0 runtime) that I want to compile into two separate EXEs - a "lite" version and a "full" version.
Unfortunately I cannot make two separate projects as it uses the Adobe Reader COM control - and sharing a form using that control between two projects seems to confuse the IDE (something to do with COM Interop, I assume - if someone knows how to share a form hosting the adobe reader control, that would solve my problem too).
I have found this thread:
Change name of exe depending on conditional compilation symbol however I don't have any MSBuild experience so I need more explicit instructions.
On the "My Project>Compile" tab there is a "Build Events..." button. I was wondering if anyone knows how to set a conditional compilation constant and use that to determine the EXE name (or change it after build).
If all else fails I can rename the EXE manually I suppose, but I'd prefer it to be automated.
如果您的解决方案中存在两个单独的项目是不可接受的,您将需要考虑创建自己的 MSBuild 脚本。
以下是自定义 MSBuild 脚本的示例,该脚本允许您在生成时定义自定义编译常量,然后生成应用程序的两个版本(“完整”和“精简版”):
您需要执行的操作:
在您的项目中,您可以使用“FULL”和“LITE”条件编译常量来确定是否编译某些语句:
If having two separate projects within your solution isn't acceptable, you'll want to look into creating your own MSBuild script.
Here is an example of a custom MSBuild script that will allow you to define your custom compilation constants at build time, and then build your two versions of your application ("Full" and "Lite"):
What you'll need to do:
Within your project, you can use the "FULL" and "LITE" conditional compilation constants to determine whether to compile certain statements: