3

我想根据是否定义了值来更改 Wix 变量的值。在我的 wixproj 中,我有:

  <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。关于我做错了什么的任何建议?

4

2 回答 2

6

That code works for me. One thing to check is that you don't have another DefineConstants MSBuild Property later in the .wixproj that doesn't look like:

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

The default .wixproj template creates projects where the Debug preprocessor variable is defined like:

<DefineConstants>Debug</DefineConstants>

And that will overwrite DefineConstants defined higher in the project for debug builds. Otherwise, everything looks fine.

于 2013-04-02T13:21:46.590 回答
2

One more thing, in addition to the @RobMensching answer.

If you build your solution using command line and msbuild, and if you define your DefineConstants in that build command, all your defines in projects will be overridden with those defined in command line:

msbuild Your.sln /t:Build
        /p:Configuration=TFSLive
        /p:Platform=x86
        /p:DefineConstants=Your;Defines;Here
于 2015-02-05T14:49:28.240 回答