Complete list of Candle preprocessor variables


Some people have asked about this in the past on the wix-users mailing list, so I thought I’d just put it here so it’s on the web searches. (We really need to do an overhaul on our WiX home page).


This is just copied verbatim from the Wix.chm file.


[Edit]: By the way, this list applies to Votive v3 and not Votive v2. Although similar, complete instructions on how to do this in Votive v2 are given in Rob’s MSDN article here (http://msdn2.microsoft.com/en-us/aa302186.aspx#wixsetup_topic9).


Project References


Introduction


The WiX Visual Studio package supports adding project references to a WiX project. This ensures that build order dependencies are defined correctly within the solution. In addition, it generates a set of WiX preprocessor definitions which are set on the Candle command line and can be referenced in source files.


Adding Project References


To add a project reference to a WiX project:



  1. Right-click on the References node of the project in the Solution Explorer and choose Add Reference…

  2. In the Add WiX Library Reference dialog, click on the Projects tab.

  3. Select the desired project(s) and click the Add button, then click OK to dismiss the dialog.

List of Supported Project References


The WiX Visual Studio package supports the following project reference variables:
















































































Variable name


Example usage


Example value


var.<ProjectName>.Configuration


$(var.MyProject.Configuration)


Debug or Release


var.<ProjectName>.FullConfiguration


$(var.MyProject.FullConfiguration)


Debug | AnyCPU


var.<ProjectName>.Platform


$(var.MyProject.Platform)


AnyCPU, Win32, x64 or ia64


var.<ProjectName>.ProjectDir


$(var.MyProject.ProjectDir)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\


var.<ProjectName>.ProjectExt


$(var.MyProject.ProjectExt)


.csproj


var.<ProjectName>.ProjectFileName


$(var.MyProject.ProjectFileName)


MyProject.csproj


var.<ProjectName>.ProjectName


$(var.MyProject.ProjectName)


MyProject


var.<ProjectName>.ProjectPath


$(var.MyProject.ProjectPath)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\MyApp.csproj


var.<ProjectName>.TargetDir


$(var.MyProject.TargetDir)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\obj\Debug\


var.<ProjectName>.TargetExt


$(var.MyProject.TargetExt)


.exe


var.<ProjectName>.TargetFileName


$(var.MyProject.TargetFileName)


MyProject.exe


var.<ProjectName>.TargetName


$(var.MyProject.TargetName)


MyProject


var.<ProjectName>.TargetPath


$(var.MyProject.TargetPath)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MyProject\obj\Debug\MyProject.exe


var.SolutionDir


$(var.SolutionDir)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MySolution\


var.SolutionExt


$(var.SolutionExt)


.sln


var.SolutionFileName


$(var.SolutionFileName)


MySolution.sln


var.SolutionName


$(var.SolutionName)


MySolution


var.SolutionPath


$(var.SolutionPath)


C:\users\myusername\Documents\Visual Studio 2005\Projects\MySolution\MySolution.sln


Example


The following File element demonstrates how to use project references in WiX authoring:

<File Id=”MyExecutable” Name=”$(var.MyProject.TargetFileName)” Source=”$(var.MyProject.TargetPath)” DiskId=”1″ />

Comments (8)

  1. Mark says:

    If I follow the add-reference instructions above, I get a dialog saying "Sorry, project references are not yet supported in Votive.  If you want to add the code, by all means! :)"

    Votive 2.0.5325

    If I right-click the project itself and choose Project Dependencies, all of the right dependencies are already listed; unfortunately, that doesn’t seem to connect to these variable definitions.

    I presume this is a 3.0-only thing?

    Thanks

    Mark

  2. MSDNArchive says:

    Mark,

    This should also work in Votive 2.0, although the preprocessor definitions may be slightly different than the ones I presented here. Take a look at Rob’s MSDN article here (http://msdn2.microsoft.com/en-us/aa302186.aspx#wixsetup_topic9) for more information on how to do this in Votive 2.0.

    Sorry about the confusion. I should have pointed this out in the blog entry.

  3. Cliff says:

    We have a problem with adding Project References when the project resides in a Visual Studio 2008 solution folder.

    The FullPath return "objecr ref not instance of an object" and we can’t access the project vars in any scripts.

    Moving project to the solution root fixes the problem. Moving it back breaks it again

    Cliff

  4. Eugene says:

    What does "MyProject" mean in this example: "$(var.MyProject.Configuration)

    "?

    I have "Infrastructure.Module" project (created by SCSF, CAB franework). When I use it like this –

    $(var.Infrastructure.Module.Configuration)

    I got compile error –

    error CNDL0150: Undefined preprocessor variable ‘$(var.Infrastructure.Module.Configuration)’

    Thank you.

  5. MSDNArchive says:

    Eugene,

    Although there could be a bug (there’s an embedded period), I think that perhaps you haven’t added the other project as a project reference in Votive? This feature won’t work unless you have added a project reference.

  6. Eugene says:

    You’re right, I have not. When I did it did not improve anything. Please allow me to explain.

    I’m using that variable in the following statement –

    <File Id="InfrastructureModuleDll" Name="CABProject.Infrastructure.Module.dll" Source="$(var.SolutionDir)bin$(var.Infrastructure.Module.Configuration)CABProject.Infrastructure.Module.dll" KeyPath="yes" />

    Once I added “Infrastructure.Module” project to the references as you have suggested I got this error –

    error LGHT0083: The file with id ‘InfrastructureModuleDll.0E7552A8_88FC_459F_9E5B_7656A0B674E4’ and name ‘xx2h3fka.dll|CABProject.Infrastructure.Module.dll’ could not be found with source path: ‘C:My ProjectsCABProject\bin\CABProject.Infrastructure.Module.dll’.

    This error exhibits two problems at the least:

    1) the “$(var.SolutionDir)” expands into “C:My ProjectsCABProject\” (two back slashes at the end) or the error message is incorrectly formatted.

    2) the “$(var.Infrastructure.Module.Configuration)” expands into a null or empty string since the file “CABProject.Infrastructure.Module.dll” exists in the “C:My ProjectsCABProjectbinDebug” folder.

    Lastly, using particular project’s configuration does not make sense since the configuration is a solution-wide concept; why should I use “Infrastructure.Module” project to get “Debug” while “Infrastructure.Library”, “Infrastructure.Interface”, and 20+ other projects have the same configuration? If you open any “.wixproj” file in Notepad you’ll see this line –

    <PropertyGroup Condition=" ‘$(Configuration)’ == ‘Debug’ ">

    where “$(Configuration)” used irrelevantly to any project at all. (The “$(var.Configuration)” produces the same CNDL0150 error)

    Thank you for your reply.

    Eugene

  7. Eugene says:

    I installed 3.0.3815.0 and "$(var.Infrastructure.Module.Configuration)” works (although when I select "Infrastructure.Module" in Solution Explorer, the "Full Path" field in Properties says: "Object reference not set to an instance of an object.")