2013-04-02 35 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