2015-02-11 39 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/>