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

Phill Hogland phill.hogland at rimage.com
Thu Mar 10 06:28:23 PST 2016


In that case I would enable a verbose build log and evaluate the output.  If building using VS then go to Tools\Options\Projects and Solutions\Build and Run and then check the log for activity with the HarvestDirectory Target

I keep my HarvestDirectory code snippet in a separate .targets file and
1) I use an import statement prior to my first ItemGroup in the .wixproj  (or you can put the code in the .wixproj file)
<Import Project="Harvest.targets" />
2) I add the harvest.targets to my vs project with compile action set to none, so that I can edit the harvest.targets in the VS IDE.
3) Any change to the harvest.targets file requires me to close the VS solution and reload the VS .sln  (I am using VS2013)
  
The harvest.targets file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <HarvestNoLogo>true</HarvestNoLogo>
    <HarvestVerboseOutput>true</HarvestVerboseOutput>
    <HarvestAutogenerateGuids>true</HarvestAutogenerateGuids>
    <HarvestSupressFragments>false</HarvestSupressFragments>
    <HarvestSuppressUniqueIds>true</HarvestSuppressUniqueIds>
  </PropertyGroup>
  <ItemGroup>
    <HarvestDirectory Include="\\server\drive\path to dir\product\parentdir as I want the folder tree installed">
      <DirectoryRefId>MyAppDir</DirectoryRefId>
      <Transforms>MyTransform.xslt</Transforms>
      <ComponentGroupName>MyAppGroup</ComponentGroupName>
      <PreprocessorVariable>var.MyApp</PreprocessorVariable>
      <KeepEmptyDirectories>false</KeepEmptyDirectories>
      <SuppressCom>true</SuppressCom>
      <SuppressRootDirectory>true</SuppressRootDirectory>
      <SuppressRegistry>true</SuppressRegistry>
      <Visible>false</Visible>
    </HarvestDirectory>
  </ItemGroup>
</Project>

Then, to a feature in my product's .wxs, I add:
      <ComponentGroupRef Id="MyAppGroup"/>

When you do a build, by default, in your intermediate path (obj\Release or obj\Debug) you will find a file named with a preceding underscore.  _MyAppGroup.wxs, and in the VS or MSBuild log the WiX target will automatically add that generated file in the list of files to be compiled.  (I describe this from memory as I do not have access to a dev/build system at the moment.)

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

I am not seeing "output wxs files are automatically added to the compiler's file list"... is there anything I have to fiddle to make that happen?

> From: phill.hogland at rimage.com
> To: wix-users at lists.wixtoolset.org
> Date: Wed, 9 Mar 2016 19:24:33 +0000
> Subject: Re: [wix-users] Unable to correctly specify a variable for WiX within Visual Studio
>
> HeatDirectory goes in the .wixproj file (or in a .Targets file that is improted into a .wixproj), generally after the PropertyGroup(s) related to selecting Configurations and before the first ItemGroup.  HeatDirectory is a MSBuild 'Target' defined by the wix build process.  There are many advantages over calling heat on the command line in my view.  The output wxs files are automatically added to the compiler's file list, and I don't have to do anything to manage whether the files are out of date and need to be rebuilt.  I used to call heat with a batch file, using the WiX define targets and Tasks is a much better approach.  As for the the VS pre-Build those are VS specific.  VS uses MSBuild to build a project and WiX integrates with MSBuild (and with VS projects).  Personally I avoid the VS specific Targets and us default MSBuild or WiX targets, which allows me to do a lot of build process customization and integration.
>



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



More information about the wix-users mailing list