我在Visual Studio中的bundle-project上创建了几个配置,我想定义每个配置中必须包含哪些代码片段。我的目标是获得几个bootstrappers:其中一些将包括先决条件,一些不会。我试过像:
<PackageGroup
Id="Prerequisites">
<?if $(Configuration)='Release'?>
<ExePackage
Id="Netfx4Client"
Cache="yes"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile=".\SupportFiles\dotNetFx40_Client_x86_x64.exe"
DetectCondition="NETFRAMEWORK40CLIENT OR (VersionNT64 AND NETFRAMEWORK40CLIENTX64)"
InstallCondition="(v4.0.30319 > NETFRAMEWORK40CLIENT OR NOT NETFRAMEWORK40CLIENT) OR (VersionNT64 AND v4.0.30319 > NETFRAMEWORK40CLIENTX64 OR NOT NETFRAMEWORK40CLIENTX64)"
InstallCommand="/q /norestart /log [TempFolder]\dotnetframework4.log"/>
<?endif?>
但当然这是不正确的..是否有可能根据任何变量管理哪些代码片段将被包含在Bundle包中?谢谢。
答案 0 :(得分:4)
是的,首先需要将MSBuild属性传递给编译器的预处理器。在.wixproj中,使用DefineConstants
属性来通过该属性。 Votive提供的默认.wixproj默认为Configuration
执行此操作,但对于其他属性,它看起来像这样:
<PropertyGroup>
<DefineConstants>$(DefineConstants);MyNewVariable=$(MSBuildPropertyName)</DefineConstants>
</PropertyGroup>
既然MSBuild属性是预处理器变量,您可以执行以下操作:
<?if $(var.Configuration)="Release" ?>
Stuff to conditionally compile out
<?endif?>
基本上,上面的示例是正确的,除非您缺少预处理程序变量名称的var.
部分。有关preprocessor syntax in the documentation的详细信息。