I have declared a property inside a PropertyGroup
in a wixproj
file.
<PropertyGroup>
<Permit>false</Permit>
</PropertyGroup>
I use this property as a Condition
to run several commands BeforeBuild
and AfterBuild
<Exec Condition=" '$(Permit)' == 'true' " Command="--command here--" />
In my Product.wxs
file, I have defined some components that I want to include or exclude based on the defined Permit
property.
<ComponentGroup Id="ProductComponents">
<ComponentRef Id="SomeComponent"/>
<!--Component to add based on the property-->
<?if $(Permit)=true ?>
<ComponentRef Id="PermissionComponent"/>
<?endif?>
</ComponentGroup>
Anytime I build the project, I get this error.
Ill-formed preprocessor variable '$(Permit)'. Variables must have a prefix (like 'var.', 'env.', or 'sys.') and a name at least 1 character long. If the literal string '$(Cache)' is desired, use '$$(Cache)'.
I have already tried all the specified prefix but it still doesn't work. Is there something I am not doing right?
You can add your variable to <DefineConstants>
wix setting in the wixproj
file. Like this (there may be already other constants defined, you probably want to keep those. Also watch out for configurations, you may need to add it for release/debug/etc):
<PropertyGroup>
<Permit>false</Permit>
</PropertyGroup>
...
<DefineConstants>Debug;Permit=$(Permit)</DefineConstants>
And then just use:
<?if $(var.Permit)=true ?>