I need to build two branded versions of my WIX based installer. The only difference between the the versions is a single bitmap containing the company contact details. I'd like to keep a single WIX project so I have less projects to maintain. I'm using an environment variable to alter which bitmap is inserted into the installer
Source="$(env.CompanyName) contact.png"
This works fine, however I cannot change the environment variable from within VS2010. VS2010 is compiling the WIX installers using the environment variables that were set when VS2010 started. I have to restart VS2010 to get it to pick up the new environment variable value.
I have 36 nested projects so I don't want to have to set the build variables within each project - that's why I'm trying to use an environment variable.
Does anyone know how to change one of the environment variables used by the current VS2010 instance? Or perhaps there is a better way?
Search and select System (Control Panel). Click on the Advanced system settings link and then click Environment Variables. Under the section System Variables, select the environment variable you want to edit, and click Edit. If the environment variable you want doesn't exist, click New.
I do this and significantly more customization in a single WiX project. I have a different project configuration for each variant. So rather than "Debug" and "Release", I have for example "Debug", "East" and "West". This only applies to the setup project. The code projects still use "Debug" and "Release". The WiX compiler can read the configuration value.
<?if $(var.Configuration)="West"?>
<?define CompanyName="West Coast Office"?>
<?elif $(var.Configuration)="East"?>
<?define CompanyName="East Coast Office"?>
<?else?>
<?define CompanyName="Debugging purposes"?>
<?endif?>
Source="$(var.CompanyName) contact.png"
Alternatively, you can add it to the setup project's preprocessor variables (Project Properties, Build, General), but again, you'll require multiple configurations:
CompanyName=West Coast Office
And in your Product.wxs:
Source="$(var.CompanyName) contact.png"
To add the configurations in Visual Studio:
Open the menu Build, Configuration Manager...
Create solution configurations
Repeat steps 2 and 3 for the other office (eg. West).
Create setup project configurations
Repeat steps 5 and 6 for West.
Delete setup project's Release configuration
Select Release and press Remove, followed by Yes and Close.
Delete solution's Release configuration
Select Release and press Remove, followed by Yes and Close.
Assign the project configurations to the solution configurations
Now when you select each solution configuration, you should have the following settings:
Solution Debug East West
------------------------------------------
Main Project Debug Release Release
Setup Project Debug East West
Finally, go into the setup project's properties and ensure everything is correct for the East and West configurations. Take note of the output folder. If that is still bin\Release, then the two configurations will overwrite eachother's output. Set it to bin\East and bin\West respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With