Problem with Environment Variables in project OutFileName


I would like to build an installer with a name reflecting the build configuration - to this end I am adding the envVars of the PlatformName, ConfigurationName (and various other VS macros).

Then I use: "MyProduct_%PlatformName%_%ConfigurationName%_1.0.0.0" for the Project.OutFileName.

When running this setup it generates MyProduct_%PlatformName%_%ConfigurationName%_1.0.0.0.wxs
and then gives the following error:

9>  Wix project file has been built: C:\_CODE_\TestWixSharp\MyProduct_%PlatformName%_%ConfigurationName%_1.0.0.0.wxs
9>C:\_CODE_\TestWixSharp\candle.exe : error CNDL0103: The system cannot find the file 'C:\_CODE_\TestWixSharp\MyProduct_x86_Debug_1.0.0.0.wxs' with type 'Source'.
So it seems like while generating the wxs file wix# doesn't substitute the environment variables. Is there a way to force it to do that just a way I can specify a totally different .wxs intermediate filename?
Closed Dec 3, 2016 at 8:22 AM by oleg_s
Fixed in v1.1


AdriaanDeHaan wrote Oct 26, 2016 at 5:00 PM

Sorry, I meant to say OutFileName not Project.Name - fixed it now

oleg_s wrote Nov 16, 2016 at 12:03 AM

There are a few things to consider...

You can control the name of the output directly from the code:
var msi = project.BuildMsi("%product%_%platform%_%config%.msi");
However expanding envars for outFils is not implemented in the current release so you have to slightly modify the code above:
var msi = project.BuildMsi("%product%_%platform%_%config%.msi".ExpandEnvVars());
The auto-expending is a good feature and the next release will have it implemented. The codebase already has the fix: Change#df806574b390.

The true problem is that you will need to set somehow the environment variables. If your MSIBuild does it for you then you are fine. But if it doesn't...

You can play with the WixSharp.targets file in the packages\WixSharp.x.x.x.x\build dir and pass the VS macros as command line variables and then use them in code:
static public void Main(string[] args)
    var msi = project.BuildMsi($"{arg[1]}_{arg[2]}_{arg[3]}.msi");
Alternatively you can modify targets file for set the envars to the VS macros. The action name is SetEnvVar and the code sample is already there. It';s just commented out.

oleg_s wrote Nov 16, 2016 at 12:05 AM

Resolved in change#df806574b390
Note released yet