I am building an Azure Devops Release pipeline and I have a WIX config file in my source code with the following structure
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define Key ="MyValue"?>
</Include>
I would like to replace "MyValue" with "MyNewValue" using the Replace Tokens package (link here)
Following the answer given here.
I have <Include>
as my token prefix and </Include>
as my token suffix. I've added the following pipeline variable:
enter image description here
When I build my pipeline it finds the file correctly, but doesn't find any variables to replace, am I missing something to link the variables step to the pipeline variables?
alternatively I was thinking the '<?' tags could be throwing it off or perhaps it's just not compatible with the WIX xml files?
Why not just pass the preprocessor variable via the .wixproj or command-line (whichever way you are building). That way you avoid the include file completely and have a much simpler solution.
I cover this technique in Episode 12 of the Deployment Dojo - All the Ways to Change. Variables and Variables. Directories and Properties:
<Project Sdk="WixToolset.Sdk/4.0.0">
<PropertyGroup>
<DefineConstants>Key=MyValue</DefineConstants>
</PropertyGroup>
</Project>
Then you can easily override the value with msbuild -p:Key=MyNewValue
.