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

moo*_*ain 1 msbuild wix wix3.5 msbuild-4.0

关于此链接提供的答案:建议的解决方案

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

我的WixValues属性看起来像这样

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

但不知何故,第二个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
Run Code Online (Sandbox Code Playgroud)

MSBuild任务看起来像这样

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

这是项目文件条目

<DefineConstants>$([MSBuild]::Unescape($(WixValues)))</DefineConstants>
Run Code Online (Sandbox Code Playgroud)

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

谢谢

moo*_*ain 6

我不能相信这一点.在wix用户找到答案 感谢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>
Run Code Online (Sandbox Code Playgroud)

你的msbuild任务中的第二个执行此操作:

<MSBuild Projects="YourWixProject.wixproj" 
   Properties="BuildNumber=$(VerBuildNumber);RevisionNumber=$(RevisionNumber)" 
/>
Run Code Online (Sandbox Code Playgroud)

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