如何将参数传递给Wix补丁?

时间:2015-02-11 09:58:50

标签: msbuild wix wix3.8

我们正在使用Wix创建补丁。它在下面给出

<Family DiskId="5000"
        MediaSrcProp="Sample"
        Name="Sample"
        SequenceStart="5000">
      <UpgradeImage SourceFile="Z:\MyViewName\Latest_UnCompressed\EmailTrans.msi" Id="Latest">
        <TargetImage SourceFile="Z:\MyViewName\Prev_Uncompressed\EmailTrans.msi" Order="2" Id="Previous" IgnoreMissingFiles="no"/>
      </UpgradeImage>
    </Family>

我不想使用<UpgradeImage SourceFile="Z:\MyViewName,因为这可能经常发生变化。 我正在使用像下面的Msbuild目标来构建它

 <Target Name="CreateUncompressFolder">

    <RemoveDir Condition="Exists('$(OldUncompressedMsiPath)')" Directories="$(OldUncompressedMsiPath)" />
    <MakeDir Condition="!Exists('$(OldUncompressedMsiPath)')" Directories="$(OldUncompressedMsiPath)" />

    <RemoveDir Condition="Exists('$(NewUncompressedMsiPath)')" Directories="$(NewUncompressedMsiPath)" />
    <MakeDir Condition="!Exists('$(NewUncompressedMsiPath)')" Directories="$(NewUncompressedMsiPath)" />

  </Target>


  <Target Name="UnCompressMsi" DependsOnTargets="CreateUncompressFolder">

    <Exec Command="msiexec.exe /a &quot;$(NewMsiPath)&quot; /qb TARGETDIR=&quot;$(NewUncompressedMsiPath)&quot;"/>

    <Exec Command="msiexec.exe /a &quot;$(OldMsiPath)&quot; /qb TARGETDIR=&quot;$(OldUncompressedMsiPath)&quot;"/>

  </Target>

  <Target Name="BuildMsp">


    <Exec Command="candle.exe &quot;$(PatchWxsName)&quot;"/>

    <Exec Command="light.exe &quot;$(WixObj)&quot; -out &quot;$(PCPName)&quot;"/>

    <Exec Command="msimsp.exe -s &quot;$(PCPName)&quot; -p &quot;$(MspName)&quot; -l &quot;Patch.log&quot; "/>

  </Target>

是否可以通过Msbuild将Z:\ MyViewName作为参数传递?

1 个答案:

答案 0 :(得分:1)

您需要使用DefineConstants并让msbuild将参数传递给.wixproj作为参数。在Automating WiX with MSBuild中,您会看到他将 PRODUCTVERSION 作为MSBUILD参数传递给wixproj,然后他可以引用 PRODUCTVERSION 在他的WXS文件中使用 $(var.PRODUCTVERSION)。 我所看到的另一种方法,在我提到的链接中几乎是相同的,而是将XML元素 DefineConstants 作为属性添加到 PropertyGroup 中。 .wixproj文件,而不是在 BeforeBuild 目标中动态创建属性。

E.x:


<Project>
<PropertyGroup>
<Configuration/>
<Platform/>
<DefineConstants>
BuildVersion=$(ProductVersion);
WixVarName=$(MSBuildPropertyName);
WixVarName1=$(MSBuildPropertyName1);
WixVarName2=$(MSBuildPropertyName2);
</DefineConstants>
<OutputPath/>
<OutputName/>