WIX MSBuild中定义的多个DefineConstants - 提出的解决方案的问题

时间:2011-04-01 16:01:57

标签: msbuild wix wix3.5 msbuild-4.0

关于此链接提供的答案:Proposed solution

我试图以多种方式使用此方法,但我无法使其工作。我已经仔细检查过我正在运行msbuild的框架4版本,我是这样,并仔细按照说明进行操作。

我的WixValues属性看起来像这样

  <PropertyGroup>
    <WixValues>
      OnBuildServer=True;
      DefineConstants=TXT=$(TXT);ProdVersion=$(InstallVersion);
      Configuration=Release;
      Platform=x64;
      SuppressAllWarnings=True;
      APPDATA=$(APPDATA);
    </WixValues>
  </PropertyGroup>

但不知何故,第二个defineconstant值没有到达命令行,即使所有其他值都可以到达那里。

The candle command line from the msbuild log looks like this:
..\WixTools\candle.exe -sw -TXT=TRUE -d"DevEnvDir=*Undefined if not building from within Visual Studio*" -d"SolutionDir=*Undefined if not building a solution or within Visual Studio*" -d"SolutionExt=*Undefined if not building a solution or within Visual Studio*" -d"SolutionFileName=*Undefined if not building a solution or within Visual Studio*" -d"SolutionName=*Undefined if not building a solution or within Visual Studio*" -d"SolutionPath=*Undefined if not building a solution or within Visual Studio*" -dConfiguration=Release -dOutDir=bin\x64\Release\ -dPlatform=x64 -dProjectDir=C:\Builds\Viper06\InstallSE64wix\ -dProjectExt=.wixproj -dProjectFileName=InstallSE64wix.wixproj -dProjectName=InstallSE64wix -dProjectPath=C:\Builds\Viper06\InstallSE64wix\InstallSE64wix.wixproj -dTargetDir=C:\Builds\Viper06\InstallSE64wix\bin\x64\Release\ -dTargetExt=.msi -dTargetFileName=InstallSE64wix.msi -dTargetName=InstallSE64wix -dTargetPath=C:\Builds\Viper06\InstallSE64wix\bin\x64\Release\InstallSE64wix.msi -out obj

MSBuild任务看起来像这样

<MSBuild
      Projects="$(SvnWorkingCopy)\InstallSE64wix\InstallSE64wix.wixproj"
      Targets="Rebuild"
      Properties="$([MSBuild]::Unescape($(WixValues)))"
      />

这是项目文件条目

<DefineConstants>$([MSBuild]::Unescape($(WixValues)))</DefineConstants>

Rory或其他任何让这个工作的人的帮助将不胜感激。

由于

1 个答案:

答案 0 :(得分:6)

我不能相信这一点。在wix users找到了答案 感谢Alex Ivanoff。

这是基本概念。 在wixproj文件中添加以下内容:

<Target Name="BeforeBuild">
    <CreateProperty Condition="$(BuildNumber) != ''"
Value="BuildNumber=$(BuildNumber);$(DefineConstants)">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
    <CreateProperty Condition="$(RevisionNumber) != ''"
Value="RevisionNumber =$(RevisionNumber);$(DefineConstants)">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>
在你的msbuild任务中第二个执行此操作:

<MSBuild Projects="YourWixProject.wixproj" 
   Properties="BuildNumber=$(VerBuildNumber);RevisionNumber=$(RevisionNumber)" 
/>

请注意,属性不是标准属性,通常它们不会通过,但在这种情况下它们会通过。其他标准属性以及非标准属性也可以正确传输。