With the wix toolset, environment variables are accessible in the .wxs file via the env preprocessor prefix, such as
$(env.TestEnvVariable)
I've configured our build pipeline to set the environment variables I need, and the msi builds fine. However, you can no longer build the .msi locally, because none of the variables are defined in the local development environment.
I'm using the wix extension for visual studio, and I've been trying to update my .wixproj files to set properties like so:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
<!-- ... some other bits -->
<PropertyGroup>
<TestEnvVariable>TestValue</TestEnvVariable>
</PropertyGroup>
</Project>
But when I try and build the msi, I get the error
Undefined preprocessor variable '$(env.TestEnvVariable)'
Additionally, I get the same error when trying to access the variable with the 'var' prefix:
Undefined preprocessor variable '$(var.TestEnvVariable)'
I understand that you can set 'var' style preprocessor variables using the define constant element
<PropertyGroup>
<DefineConstants>SomeOtherVariable=someValue</DefineConstants>
</PropertyGroup>
But in our hosted pipelines we are setting these variables as environment variables, because that is easily surfaced in what we're using (azure devops). I could convert all those 'env' variables to 'var' via redefining them all, but that seems unnecessarily complicated, and I would like to maintain their distinction as environment variables. My goal is to allow local dev builds to use the same variable structure, just set them conditionally on configuration=Debug or something.
Is there no better way to set 'env' preprocessor variables for local dev other than conditionally running a batch file to set TestEnvVariable=TestValue
?