Wix 'undefined preprocessor variable'

2019-08-12 02:18发布

问题:

I have seen questions like this, but they seem to not help me.

I am playing with a test web application.

I added this into my RStp.wixproj, I had a hard time, but it works, it generates the Frags.wxs:

<Target Name="BeforeBuild">
    <Exec Command=" &quot;$(WiX)bin\heat.exe&quot; project &quot;..\WebR\WebR.csproj&quot; -cg Portals.Vendor -gg -pog Binaries -pog Content –configuration &quot;release&quot; -platform &quot;AnyCPU&quot; –out &quot;Frags.wxs&quot; " />
    <ItemGroup>
      <Compile Include="Frags.wxs" />
    </ItemGroup>
  </Target>

My Frags.wxs looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebR.Binaries" />
    </Fragment>
    <Fragment>
        <ComponentGroup Id="WebR.Binaries">
            <ComponentRef Id="cmp7AE3B693619BAD570BB795DC740F74CA" />
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="WebR.Content">
            <Directory Id="dirBB5AA78A6132241A7A39F7899E66D36C" Name="Fold" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="WebR.Content">
            <ComponentRef Id="cmp434BA57B5F42786DB41F7D30B9C8A2AA" />
            <ComponentRef Id="cmp827A8854133966F2160835E612413FA7" />
            <ComponentRef Id="cmpF279DD78D3B3BE5386C8535E2A85FC5F" />
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="Portals.Vendor">
            <Component Id="cmp7AE3B693619BAD570BB795DC740F74CA" Directory="WebR.Binaries" Guid="{9F6BEFC1-6226-4C1D-A1B0-1C7D6355DB60}">
                <File Id="filB23D27862A7D96131D5E2F7C7CCCAA8B" Source="$(var.WebR.TargetDir)\WebR.dll" />
            </Component>
            <Component Id="cmp434BA57B5F42786DB41F7D30B9C8A2AA" Directory="WebR.Content" Guid="{F0733DE8-9B04-4F65-ABA3-954B71E6CC00}">
                <File Id="fil85B5BB89317EA74AFB68409ADF6BA4C7" Source="$(var.WebR.ProjectDir)\Default.aspx" />
            </Component>
            <Component Id="cmp827A8854133966F2160835E612413FA7" Directory="WebR.Content" Guid="{ADF5B995-9002-469F-BA2F-9A88621DAF13}">
                <File Id="filFD9C307A451419BA8B1308C1786045D2" Source="$(var.WebR.ProjectDir)\Web.config" />
            </Component>
            <Component Id="cmpF279DD78D3B3BE5386C8535E2A85FC5F" Directory="dirBB5AA78A6132241A7A39F7899E66D36C" Guid="{8BFCFDD6-E995-482D-9AA3-4EE8926E9CB0}">
                <File Id="filB2AF43969CEF48A8A2E362F2D8E5DD20" Source="$(var.WebR.ProjectDir)\Fold\F2.aspx" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

I have not yet made any changes to the Product.wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="RStp" Language="1033" Version="1.0.0.0" Manufacturer="Prive" UpgradeCode="cfbe56e5-e27a-42c3-af88-262956974943">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="RStp" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="RStp" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
                <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->
        </ComponentGroup>
    </Fragment>
</Wix>
  1. What do I have to do to have the A.R.Facade inside the Frags.wxs ?
  2. How do I link the Frags.wxs into the Product.wxs?
  3. How do I fix the Error 'Undefined preprocessor variable '$(var.WebR.TargetDir)' UPDATE Right Click on RStp, add reference, select Web prj - fixed
  4. Where do I have to add the Candle code (RStp.wixproj like for heat?) and what should that look like?
  5. If this would be on sourcesafe, should I include the Frags.wxs into the sources?
  6. I need to have a specific install path that looks like this: 'E:\Inetpub\wwwroot', how can I set this up?

Thanks

回答1:

1.) You'll need to reference the Components/ComponentGroups inside your feature

    <Feature Id="ProductFeature" Title="RStp" Level="1">
        <ComponentGroupRef Id="Portals.Vendor" />
        <ComponentGroupRef Id="WebR.Content" />
        <ComponentGroupRef Id="WebR.Binaries" />
    </Feature>

2.) There's no linking in the traditional sense in WiX. All of your components can be referenced from other WiX files in that project.

3.) In your Project Properties of RStp under the Build tab you can define WebR.TargetDir to be the directory path that heat is being launched on

4.) Since you are already using Visual Studio why not just let it handle compiling?

5.) Since Frags.xml will be generated every time I would not add it to Source Safe where it would need to lock the file to edit it. We use SVN and have added the autogen files as we've found it useful when working on the installs to see files that have been added or removed.

6.) Take a look at this