2013-04-02 31 views
2

我想根据定义的值或其他值来更改Wix变量的值。在我wixproj我:Wix条件和预处理器变量

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'TFS Live|x86' "> 
    <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath> 
    <IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath> 
    <WixVariables>LIVE</WixVariables> 
    <DefineConstants>LIVE</DefineConstants> 
    </PropertyGroup> 

...在我WXS我:

<?ifdef LIVE ?> 
<?define binaryPath = "C:\Builds\5\IT Aerodynamics\RBT.TestSpec.LiveRelease\Binaries" ?> 
<?else?> 
<?define binaryPath = "C:\Builds\5\IT Aerodynamics\RBT.TestSpec.CI\Binaries" ?> 
<?endif?> 

...但是当我建立了相应的配置,和ifdef永远不会触发。我总是得到binaryPath的第二个值。任何关于我在做什么的错误?

回答

2

该代码适用于我。有一点要检查的是你没有其他DefineConstants MSBuild的属性后面的.wixproj这看起来并不像:

<DefineConstants>$(DefineConstants);OtherVars=Value</DefineConstants> 

默认.wixproj模板创建其中Debug预处理器变量等被定义项目:

<DefineConstants>Debug</DefineConstants> 

而且这将覆盖DefineConstants定义为更高的项目调试版本。否则,一切看起来都很好。

1

还有一件事,除了@RobMensching的答案。

如果您使用命令行的MSBuild构建解决方案,如果你在构建命令定义DefineConstants,在项目所有的定义将与那些在命令行中定义被重写:

msbuild Your.sln /t:Build 
     /p:Configuration=TFSLive 
     /p:Platform=x86 
     /p:DefineConstants=Your;Defines;Here