I am required to create an installer that will install the files on Program
Files or Program Files(x86) depending upon the OS. Upon installation, I
want to create another folder inside CommonAppDataFolder and write the
newly created folder in environement path.

I have attached the code below:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
    <Product Id="*" Name="InstallCreateCommFolder" Language="1033"
Version="1.0.0.0" Manufacturer="Sarvagya"
UpgradeCode="74f5ce5a-dcd0-42d7-bd58-4e03ae19f19c">
        <Package InstallerVersion="200" Compressed="yes"
InstallScope="perMachine" />

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

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

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER"
Name="InstallCreateCommFolder" />
            </Directory>
      <Directory Id="CommonAppDataFolder">
        <Directory Id="MyAppDataFolder" Name="MyFolder" />
      </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="MainFile">
        <File
         Id="SomeExe"
         Name="someExe.exe"
         DiskId="1"
         Source="..\..\LearningCPP\Debug\LearningCPP.exe"
         Vital="yes"
         KeyPath="yes" />
      </Component>
        </ComponentGroup>
    </Fragment>

  <Fragment>
    <ComponentGroup Id="AppDataComponents" Directory="MyAppDataFolder">
      <Component Id="CreateTheAppFolder">
        <CreateFolder Directory="MyAppDataFolder" />
      </Component>
      <Component Id="EnvPathWrite">
        <Environment Action="set"  Id="EnvPath" Name="EnvPath"
Permanent="no" System="yes" Part="last" Value="[MyAppDataFolder]"/>
        <CreateFolder/>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

​But when I try to compile this program, I get error  " Error    1    The
Component/@Guid attribute's value '*' is not valid for this component
because it does not meet the criteria for having an automatically generated
guid. Components using a Directory as a KeyPath or containing
ODBCDataSource child elements cannot use an automatically generated guid.
Make sure your component doesn't have a Directory as the KeyPath and move
any ODBCDataSource child elements to components with explicit component
guids.
E:\Sarvagya\LearningStuffs\InstallCreateCommFolder\InstallCreateCommFolder\Product.wxs
42" and  " Error    2    The Component/@Guid attribute's value '*' is not
valid for this component because it does not meet the criteria for having
an automatically generated guid. Components using a Directory as a KeyPath
or containing ODBCDataSource child elements cannot use an automatically
generated guid. Make sure your component doesn't have a Directory as the
KeyPath and move any ODBCDataSource child elements to components with
explicit component guids.
E:\Sarvagya\LearningStuffs\InstallCreateCommFolder\InstallCreateCommFolder\Product.wxs
45"


​If I forcefully create a GUID and write into Component, it works. But I
don't think it is the correct way to create a folder and write into
Environment Path. Please correct the code. Thank you

-- 

*Sarvagya Pant*
*Kathmandu, Nepal*
*+9779803468257*
------------------------------------------------------------------------------
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to