[wix-users] Unable to correctly specify a variable for WiX within Visual Studio

Phill Hogland phill.hogland at rimage.com
Wed Mar 9 10:13:01 PST 2016


The .wixproj file is a MSBuild file processed by MSBuild and would have no concept of the WiX Preporcessor syntax.  If you want to use the WiX preprocessor syntax it needs to be in a .wxs file.

But I think another approach is the solution to what you are trying to do.
1) in the .wixproj file define the path to a common area where you have .wxi include files.  (I only do this for includes that are used in more than one project.) 

Put this PropertyGroup after your last 'config' specif propert group and before your first ItemGroup.
  <PropertyGroup>
    <CompilerAdditionalOptions>
      $(CompilerAdditionalOptions)
      -I"$(MSBuild Property or EnvironmentVariable)\Common\Src\Includes"
    </CompilerAdditionalOptions>
  </PropertyGroup>

Then in your .wxs file just use the Prepprocessor syntax without a path:

<!-- This include file is found at the path defined using the -I command in the .wixproj file.-->
<?include commonIncludes.wxi ?>
<?include ver.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:swid="http://schemas.microsoft.com/wix/TagExtension">

...........
</wix>




________________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Jon Earle <earlej at hotmail.com>
Sent: Wednesday, March 9, 2016 10:36 AM
To: WiX Toolset Users Mailing List
Subject: Re: [wix-users] Unable to correctly specify a variable for WiX within Visual Studio

So, I created an include file, specified within it:
<?define JavaDocsBase = "c:\javadocs" ?>
Then edited the wixproj file to see if I could pull it in:
<?xml version="1.0" encoding="utf-8"?><?include $(sys.CURRENTDIR)\Config.wxi?><Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Tried to re-load the project file and still get
 error  : The expression """.JavaDocsBase" cannot be evaluated. Method 'System.String.JavaDocsBase' not found.
I thought that the project file would pull in and therefore have available, the variable I defined... why does it not find it?
Thanks!Jon
> From: Jacob.Hoover at greenheck.com
> To: wix-users at lists.wixtoolset.org
> Date: Tue, 8 Mar 2016 20:48:19 +0000
> Subject: Re: [wix-users] Unable to correctly specify a variable for WiX within        Visual Studio
>
> <PropertyGroup>
>   <JavaDocBase>c:\javadocs</JavaDocBase>
> <DefineConstants>
>       $(DefineConstants);
>       VersionMajorMinor=$(VersionMajorMinor);
>       VersionBuild=$(VersionBuild);
>       VersionQFE=$(VersionQFE);
>       BundleUpgradeCode=$(BundleUpgradeCode);
>       JavaDocBase=$(JavaDocBase);
> </DefineConstants>
> </PropertyGroup>
>
> Should work if you are referring to them in your WXS via
>
> <Bundle Version="$(var.VersionMajorMinor).$(var.VersionBuild).$(var.VersionQFE)"
>           UpgradeCode="$(var.BundleUpgradeCode)"
> ...
>
> If you have a PreBuild event, use the MSBuild property instead of the var syntax.
>
> <PreBuildEvent>"$(WIX)bin\heat.exe" dir "$(JavaDocBase)" -cg JavaDocs_JSP -gg -scom -sreg -sfrag -srd -dr INSTALLDIR -var var.JavaDocBase -out "$(ProjectDir)\JavaDocs_JSP_Fragment.wxs"</PreBuildEvent>
>
>
> I am a bit confused why you opted not to use the HeatDirectoryTask.
>
> -----Original Message-----
> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Jon Earle
> Sent: Tuesday, March 08, 2016 1:15 PM
> To: wix-users at lists.wixtoolset.org
> Subject: [wix-users] Unable to correctly specify a variable for WiX within Visual Studio
>
> Setup is Wix 3.10.2 and visual studio 2015. Working with a wix setup project and custom action project.
> I want to create a fragment containing the javados for my project. I had read (http://weblogs.sqlteam.com/mladenp/archive/2010/02/11/WiX-3-Tutorial-SolutionProject-structure-and-Dev-resources.aspx) to set a pre-processor variable (or system variable). I opted to include the variable definition in the project. I tried the pre-processor var <DefineConstants>JavaDocBase=c:\javadocs</DefineConstants>
> and just setting a normal variable:
> <WixVariables>JavaDocBase=c:\javadocs</WixVariables>
> Neither ended up working.
> Pre-Build event:
> <PropertyGroup><PreBuildEvent>"$(WIX)bin\heat.exe" dir "$(var.JavaDocBase)" -cg JavaDocs_JSP -gg -scom -sreg -sfrag -srd -dr INSTALLDIR -var var.JavaDocBase -out "$(ProjectDir)\JavaDocs_JSP_Fragment.wxs"</PreBuildEvent></PropertyGroup>
> I always seem to receive the error:
> Unhandled Exception:The expression """.JavaDocBase" cannot be evaluated. Method 'System.String.JavaDocBase' not found.
> I have tried var.JavaDocBase, wix.JavaDocBase, env.JavaDocBase and Just JavaDocBase... while the last will allow the command to run, it doesn't put in the proper path so I am no further ahead.
> Is it possible to replicate what is in that previously linked tutorial and if so, what have I done wrong?
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/


____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list