Reputation: 18147
We are creating patch using Wix. It is given below
<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>
I do not want to use <UpgradeImage SourceFile="Z:\MyViewName
, Because this may change often.
I am using Msbuild target like below to build it
<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 "$(NewMsiPath)" /qb TARGETDIR="$(NewUncompressedMsiPath)""/>
<Exec Command="msiexec.exe /a "$(OldMsiPath)" /qb TARGETDIR="$(OldUncompressedMsiPath)""/>
</Target>
<Target Name="BuildMsp">
<Exec Command="candle.exe "$(PatchWxsName)""/>
<Exec Command="light.exe "$(WixObj)" -out "$(PCPName)""/>
<Exec Command="msimsp.exe -s "$(PCPName)" -p "$(MspName)" -l "Patch.log" "/>
</Target>
Is it possible to pass Z:\MyViewName as parameter via Msbuild ?
Upvotes: 0
Views: 1153
Reputation: 2056
You need to use the DefineConstants and have msbuild pass in parameters to your .wixproj as parameters. In Automating WiX with MSBuild, you'll see he's passing in PRODUCTVERSION as a MSBUILD parameter to the wixproj and he can then reference the value of PRODUCTVERSION using $(var.PRODUCTVERSION) in his WXS file. Another approach I've seen done, which is pretty much the same in the link i mentioned is to instead add the XML element DefineConstants as a property to the PropertyGroup in the .wixproj file instead of creating the property on the fly in the BeforeBuild target.
E.x.:
<Project>
<PropertyGroup>
<Configuration/>
<Platform/>
<DefineConstants>
BuildVersion=$(ProductVersion);
WixVarName=$(MSBuildPropertyName);
WixVarName1=$(MSBuildPropertyName1);
WixVarName2=$(MSBuildPropertyName2);
</DefineConstants>
<OutputPath/>
<OutputName/>
Upvotes: 1