6

My first question is, should I work to get the compiler working with auto-generated guids?

I am trying to create an installer for a website with WiX. Please excuse my ignorance, this is my first WiX project. I am following this article:

http://blog.bartdemeyer.be/2013/10/create-an-installer-for-website-with-wix-part-1/

The process uses msbuild to call several WiX tools to ultimately create an MSI. The example uses "Generate guids now" (the "-gg" switch) when calling heat:

<Target Name="Harvest">
    <!-- Harvest all content of published result -->
    <Exec
        Command='"$(WiX)bin\heat.exe" dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MgrWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
        ContinueOnError="false"
        WorkingDirectory="." />
</Target>

I was reading elsewhere it is best practice to use auto-generated guids (the -ag switch) to ensure product updates install correctly. I notice the guids change every time heat is run.

<Fragment>
    <ComponentGroup Id="MgrWebComponents">
        <Component Id="cmp56294569B275493319100C26538BA16C" Directory="INSTALLFOLDER" Guid="{A43DA07B-C4CD-4FE0-AC09-EEA693AB2BA7}">
            <File Id="fil93D55732EC03C2B809F21B9423BF5550" KeyPath="yes" Source="$(var.publishDir)\BrandImageService.ashx" />
        </Component>
        <Component Id="cmp6BD39B2D572EA73C29A81AE5D1C3F0C4" Directory="INSTALLFOLDER" Guid="{99B7B916-AEC0-4EE9-B17F-E7B325E93A4D}">
            <File Id="filE861424851E26D456D43F5D1855B3E7B" KeyPath="yes" Source="$(var.publishDir)\Dashboard.aspx" />
        </Component>
...

If I should use auto-generated guids I need to get the compiler working. I am getting errors for every file for trying to use auto-generated guids when compiling.

LGHT0231: The component 'cmp2BE6B5C092821452E1438D39A5110DDB' has a key file with path 'TARGETDIR\inetpub\manager\tools\toolshome.aspx'. Since this path is not rooted in one of the standard directories (like ProgramFilesFolder), this component does not fit the criteria for having an automatically generated guid. (This error may also occur if a path contains a likely standard directory such as nesting a directory with name "Common Files" under ProgramFilesFolder.)

My directory fragment is:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="INETPUB" Name="Inetpub">
            <Directory Id="INSTALLFOLDER" Name="Manager" />
        </Directory>
    </Directory>
</Fragment>

The heat generated fragment looks like:

<Fragment>
    <ComponentGroup Id="MgrWebComponents">
        <Component Id="cmp56294569B275493319100C26538BA16C" Directory="INSTALLFOLDER" Guid="*">
            <File Id="fil93D55732EC03C2B809F21B9423BF5550" KeyPath="yes" Source="$(var.publishDir)\BrandImageService.ashx" />
        </Component>
        <Component Id="cmp6BD39B2D572EA73C29A81AE5D1C3F0C4" Directory="INSTALLFOLDER" Guid="*">
            <File Id="filE861424851E26D456D43F5D1855B3E7B" KeyPath="yes" Source="$(var.publishDir)\Dashboard.aspx" />
        </Component>
...

The targets for msbuild:

<Target Name="Build">
    <!-- Compile whole solution in release mode -->
    <MSBuild
        Projects="..\Manager.sln"
        Targets="ReBuild"
        Properties="Configuration=Release" />
</Target>

<Target Name="PublishWebsite">
    <!-- Remove complete publish folder in order to 
            be sure that everything will be newly compiled -->
    <Message Text="Removing publish directory: $(SetupF)"/>
    <RemoveDir Directories="$(SetupF)" ContinueOnError="false" />
    <Message Text="Start to publish website" Importance="high" />
    <MSBuild
        Projects="..\\Manager\UI\Manager.UI.csproj"
        Targets="ResolveReferences;_CopyWebApplication"
        Properties="OutDir=$(Publish)bin\;WebProjectOutputDir=$(Publish);Configuration=Release" />
</Target>

<Target Name="Harvest">
    <!-- Harvest all content of published result -->
    <Exec
        Command='"$(WiX)bin\heat.exe" website $(Publish) -dr INSTALLFOLDER -ke -srd -cg MgrWebComponents -var var.publishDir -ag -out $(WebSiteContentCode)'
        ContinueOnError="false"
        WorkingDirectory="." />
</Target>

<Target Name="WIX">
    <!--     At last create an installer -->
    <Message Text="TEST: @(WixCode)"/>
    <Exec
        Command='"$(WiX)bin\candle.exe" -dpublishDir=$(Publish) -dMgrWebResourceDir=. @(WixCode, &apos; &apos;)'
        ContinueOnError="false"
        WorkingDirectory="." />
    <Exec
        Command='"$(WiX)bin\light.exe" -spdb -out $(MsiOut) @(WixObject, &apos; &apos;)'
        ContinueOnError="false"
        WorkingDirectory="." />

    <!-- A message at the end -->
    <Message Text="Install package has been created." />
</Target>

The build command is: msbuild /t:Build;PublishWebsite;Harvest;WIX setup.build

I understand the generated guid uses the seed of the directory. Should I change the location of the directory?

Thank you!!

sean
  • 1,187
  • 17
  • 25
  • Have you tried using the website directive for heat instead of the dir, can't test right now but here's the link http://wixtoolset.org/documentation/manual/v3/overview/heat.html – CheGueVerra Jan 28 '15 at 03:30
  • Thank you for the suggestion. I tried that and said it could not find the website. Probably because it is just a directory. I will look more into the website option. – sean Jan 28 '15 at 17:48
  • Did you run the heat website in the Published folder of the WebSite ? – CheGueVerra Jan 28 '15 at 19:34
  • Yes I believe msbuild is starting a publish after the directory is removed and before heat is run. I added all of the msbuild targets so you can see what it all does. – sean Jan 28 '15 at 20:46
  • can you put your msbuild command line so I go through the targets in the same order as you. I'll be trying to do the same on one of my tests projects here at work, keep you posted if I find something for you – CheGueVerra Jan 28 '15 at 21:02
  • Certainly! I added it just below the targets xml. It runs in the same order as it is listed. – sean Jan 28 '15 at 21:31
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/69770/discussion-between-chegueverra-and-sean). – CheGueVerra Jan 28 '15 at 21:37
  • duplicate of https://stackoverflow.com/questions/7328748/harvesting-files-leads-to-lght0231-error – john k Jul 01 '21 at 13:43

1 Answers1

3

Thank you to @CheGueVerra , he pointed me in the right direction. I just changed the directory location to be in ProgramFiles and it was able to compile.

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

Later on I found a better way with the use of the "ComponentGuidGenerationSeed" attribute to keep the directory in the inetpub folder.

<Directory Id='TARGETDIR' Name='SourceDir'>
    <Directory Id="IISMain" Name='inetpub'>
        <Directory Id="WWWMain" Name='wwwroot' 
           ComponentGuidGenerationSeed='{Put-your-own-generated-guid-here}'>
            <Directory Id='INSTALLFOLDER' Name='Manager'>
            </Directory>
        </Directory>
    </Directory>
</Directory>
sean
  • 1,187
  • 17
  • 25