2015-02-11 44 views
0

我们正在使用Wix创建补丁。它被赋予以下如何将参数传递给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> 

是否可以通过Z:\ MyViewName为通过MSBuild的参数?

回答

1

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

E.x:

 

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