Create folders in wix - visual-studio-2012

I want to create a folder in C drive and then create some sub folders inside that folder in the wix installer program. But these folders are not related with installed folder. . My program want to install inside the AServiceSetup folder...but i want to create a 'PTLogFile' folder inside the C drive and then want to create some sub folders inside that folder. Please any one help me to correct my code.Following is my code
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="PTLogFile" Name="PTLogFile">
<Directory Id="Backups" Name="Backups"/>
<Directory Id="CommandLog" Name="CommandLog"/>
<Directory Id="EventLog" Name="EventLog"/>
<Directory Id="Responds" Name="Responds"/>
</Directory>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="AServiceSetup">
</Directory>
</Directory>
</Directory>
</Fragment>

Thank you for your replies. I got the answer from the above replies
Directory structure as follows
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="LogFile" Name="LogFile">
<Directory Id="Logs" Name="Logs">
<Directory Id="Log1" Name="Log1"/>
<Directory Id="Log2" Name="Log2"/>
<Directory Id="Log3" Name="Log3"/>
<Directory Id="Log4" Name="Log4"/>
</Directory>
</Directory>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="AServiceSetup">
</Directory>
</Directory>
</Directory>
And Component as follows
<Component Id="CreateLogFolders" Guid="....." Directory="LogFile" >
<CreateFolder Directory="LogFile" />
<CreateFolder Directory="Logs"/>
<CreateFolder Directory="Log1"/>
<CreateFolder Directory="Log2"/>
<CreateFolder Directory="Log3"/>
<CreateFolder Directory="Log4"/>
</Component>
and this component reference inside the feature of the product as follows
<ComponentRef Id="CreateLogFolders"/>
Finally add a property inside the product as follows
<Property Id="LogFile" Value="C:" />

While you have defined a directory structure, the installer is only going to create directories that are required by components.
A simple option is to add a component like the following:
<Component Id="CreateLogFolders" Directory="PTLogFile">
<CreateFolder Directory="PTLogFile" />
<CreateFolder Directory="Backups" />
<CreateFolder Directory="CommandLog" />
<CreateFolder Directory="EventLog" />
<CreateFolder Directory="Responds" />
</Component>
and reference this component in one of your features.

You'd rather place each <CreateFolder> element, which results in a record to CreateFolder table, in its own component. Otherwise, I'm not sure this complies well with component rules...
Leave the directory structure as follows:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="PTLogFile" Name="PTLogFile" />
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="AServiceSetup">
</Directory>
</Directory>
And author the component in the way similar to this:
<DirectoryRef Id="PTLogFile">
<Directory Id="Backups">
<Component Id="..." Guid="...">
<CreateFolder />
</Component>
</Directory>
<Directory Id="CommandLog">
<Component Id="..." Guid="...">
<CreateFolder />
</Component>
</Directory>
<Directory Id="EventLog">
<Component Id="..." Guid="...">
<CreateFolder />
</Component>
</Directory>
<Directory Id="Responds">
<Component Id="..." Guid="...">
<CreateFolder />
</Component>
</Directory>
</DirectoryRef>

Related

Using Wix to generate an MSI

I am using Wix 3.8 to create an MSI installer for a Visual Studio project I have created. I followed this simple tutorial but even with this simply Wix project I am getting errors. Here is My
I have added my VS2012 project as a reference to my Wix Installer.
Here is my Product.ws file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
<Product Id="*" Name="MyProjectInstaller2" Language="1033" Version="2.0.0.0" Manufacturer="Company" UpgradeCode="7f5b63be-bdad-4cc9-b4df-b3f1648c0539">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MyProjectInstaller2" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MyProjectInstaller2" />
</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"> -->
<File Source="$(var.MyProject.TargetPath)" />
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>
When I compile this, I get the following error:
The ComponentGroup element contains an unexpected child element 'File'.
I have searched the bowels of the internet for a solution to this very basic problem. Why is VS2012 not recognising the element?
You should follow next hierarchy: ComponentGroup -> Component -> File and etc. In your example i suggest to you to put File element into separated component and then add this component into ComponentGroup. Try something like this:
<Component Directory="YOUR-DIRECTORY" Guid="your-guid" Id="SomeComponent">
<File Source="$(var.MyProject.TargetPath)"/>
</Component>
<ComponentGroup Directory="INSTALLFOLDER" Id="ProductComponents">
<ComponentRef Id="SomeComponent"/>
</ComponentGroup>
Read the TODO comment right above your <File Source>
You need to remove the comments around <Component Id="ProductComponent"> and </Component>.

Issue with Wix Web application Setup into IIS virtual directory

I trying to install web application into virtual directory i.e. "c:\Inetpub\XYZ". But it is installing into "D:\XYZ" or Mysource directory is "D:\". Can any body help me how to install into website location (XYZ) in IIS virtual directory("C:\Inetpub\XYZ").
<Directory Id="INSTALLDIR" Name="XYZ">
<Component Id="VirtualDirectoryComponent" Guid="DED95D72-52AE-4258-9D50-687E65449F95">
<CreateFolder />
<iis:WebVirtualDir Id="My.VirtualDir" Alias="[WEB_APP_NAME]" Directory="INSTALLDIR" WebApplication="" WebSite="DefaultWebSite">
<iis:WebApplication Id="Application" Name="[WEB_APP_NAME]" />
<iis:WebDirProperties Id="WebSite_Properties" AnonymousAccess="yes" WindowsAuthentication="no" DefaultDocuments="Default.aspx" Script="yes"
Read="yes" />
</iis:WebVirtualDir>
</Component>
</Directory>
</Directory>
Try replacing the directory with following
Directory Id='TARGETDIR' Name='SourceDir'>
<!-- Install into the ISS root directory -->
<Directory Id="IISROOT" Name='WebDir'>
<!-- Here's this installers install location. -->
<Directory Id='INSTALLDIR' Name='XYZ'></Directory>
</Directory>

how to fix warning ICE39: Admin Image flag set in SummaryInfo stream

I am creating an installer using Wix in visual studios 2012. Below is my code for the product.wxs. I am receiving a "warning ICE39: 'Admin Image' flag set in SummaryInfo stream. Should be set only for Admin packages." I have changed admin image from yes to no and rebuilt, it removes the warning but i am still unable to install on a computer that has local admin privileges, and is also a domain admin. However, i can install it on my machine, and im not a domain admin,
I would upload the image but not enough rep yet. here is an image link.
http://i656.photobucket.com/albums/uu290/chrizbahr/warning_zps12f388b2.png
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductName="CHC Pedometer Sync"?>
<?define ProductVersion="1.0.0"?>
<?define ProductGUID="{6D234D2C-5F74-42A8-A9DA-14D684B2EAFC}"?>
<?define ProductUpgradeCode="{DDDD43E0-DB34-4AD6-BF54-F6B12509E84F}"?>
<?define Manufacturer="CHC Wellness"?>
<Product Id="$(var.ProductGUID)"
Name="$(var.ProductName)"
Language="1033"
Version="$(var.ProductVersion)"
Manufacturer="$(var.Manufacturer)"
UpgradeCode="$(var.ProductUpgradeCode)">
<Package Id="*"
Description="CHC Pedometer Sync Installer"
Keywords="Installer"
Manufacturer="$(var.Manufacturer)"
SummaryCodepage="1252"
InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
AdminImage="yes"
InstallPrivileges="limited" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<!--DIRECTORY STRUCTURE-->
<Directory Id="TARGETDIR" Name="SourceDir">
<!--PROGRAM FILES-->
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="CHCWellness" Name="CHC Wellness">
<Directory Id="INSTALLDIR" Name="$(var.ProductName)" />
</Directory>
</Directory>
<!--DESKTOP-->
<Directory Id="DesktopFolder" Name="Desktop"/>
<!--START MENU-->
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="$(var.Manufacturer)" />
</Directory>
</Directory>
<DirectoryRef Id="INSTALLDIR">
<Component Id="MainExecutable" Guid="{FB74004F-F250-4B3C-B38C-D96D5657A27A}">
<File Id="File_MainExecutable" Source="..\PedometerSync\bin\Release\PedometerSync.exe" Vital="yes" DiskId="1" KeyPath="yes">
<Shortcut Id="MainExeShortcutDesktop"
Name="$(var.ProductName)"
Directory="DesktopFolder"
Description="$(var.ProductName)"
WorkingDirectory="INSTALLDIR"
Advertise="yes"
Icon="icon.ico" />
</File>
</Component>
<Component Id="InterfaceExe" Guid="{68C78DE2-BEBB-41D7-B9F6-313BCFC88F68}">
<File Id="PedometerInterfaceEXE" Source="..\PedometerSync\bin\Release\PedometerInterface.exe" Vital="yes" DiskId="1" KeyPath="yes" />
</Component>
<Component Id="EXEConfig" Guid="{8D9F2744-C1E4-45E1-88E7-C3427200767E}">
<File Id="File_ExeConfigFile" Source="..\PedometerSync\bin\Release\PedometerSync.exe.config" Vital="yes" DiskId="1" KeyPath="yes" />
</Component>
<Component Id="Newtonsoft" Guid="{09343B58-A247-4AA9-9A32-A6CB1BD9CC2F}">
<File Id="file_newtonsoft.json.dll" Source="..\PedometerSync\bin\Release\Newtonsoft.Json.dll" Vital="yes" DiskId="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<!--SHORTCUTS-->
<DirectoryRef Id="ProgramMenuDir">
<Component Id="StartMenuShortcut" Guid="{E02282A4-0907-4EC6-A5B7-623E50B4E642}">
<Shortcut Id="MainExeShortcut"
Name="$(var.ProductName)"
Description="$(var.ProductName)"
Target="[INSTALLDIR]PedometerSync.exe"
Icon="icon.ico"/>
<RemoveFolder Id="RemoveStartMenuShortcutDir" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<!--FEATURES LIST-->
<Feature Id="Standard" Level="1">
<ComponentRef Id="MainExecutable"/>
<ComponentRef Id="InterfaceExe"/>
<ComponentRef Id="EXEConfig"/>
<ComponentRef Id="Newtonsoft"/>
<ComponentRef Id="StartMenuShortcut"/>
</Feature>
<!--ADD UI ELEMENTS-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<UIRef Id="WixUI_InstallDirCustom" />
<UIRef Id="WixUI_ErrorProgressText" />
<!--CUSTOM IMAGES-->
<WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="dialog.bmp" />
<!--ICONS-->
<Icon Id="icon.ico" SourceFile="icon.ico" />
</Product>
</Wix>
Remove the Admin attribute. This attribute doesn't refer to needing admin rights to install a package, it refers to whether the MSI is a normal Installation or an Administrative Installation.
For more information, see the help topics:
Administrative Installation (Windows)
Word Count Summary property (Windows) (Notice the definition of bit 2 and bit 3 these correlate to the AdminImage and InstallPrivileges attributes respectively)

wix virtual directories under default web site not uninstalled, conflict with other features?

I am building an installer using wix for several .net web applications. I have two features, one of which installs several virtual directories / applications under default web site in IIS. The second feature creates a separate website with a single virtual directory.
The problem is when I install both features, the virtual directories (from feature 1) under default web site are not removed during the uninstall. The strange part is that if I just install feature 1 (exclude feature 2) the uninstall works properly for feature 1 and the virtual directories are removed.
I am new to wix, I'm guessing something is wrong with my product.wxs or there is something Im not understanding. Thoughts?
Here is a sample snippet from my product.wxs file :
<Feature Id="feature1" Title="feature1" Description="feature 1 description" Level="1" ConfigurableDirectory="INSTALLDIR" Display="expand">
...
<ComponentGroupRef Id="IIS_Feature1" />
</Feature>
<Feature Id="feature2" Title="feature2" Description="feature 2 description" Level="1" ConfigurableDirectory="INSTALLDIR" Display="expand">
...
<ComponentGroupRef Id="IIS_Feature2" />
</Feature>
<Directory Id="TARGETDIR" Name="SourceDir">
...
<Directory Id="ROOT_DRIVE">
<Directory Id="Inetpubdir" Name="inetpub">
<Directory Id="wwwrootdir" Name="wwwroot" />
<Directory Id="wwwrootcustom" Name="wwwroot-custom" />
</Directory>
</Directory>
</Directory>
<ComponentGroup Id="IIS_Feature1">
<Component Id="IIS_WebApp1" Guid="some-guid-1" Directory="wwwrootdir" KeyPath="yes">
<iis:WebVirtualDir Id="WebApp1VirtualDir" Alias="webapp1" WebSite="DefaultWebSite" Directory="WEBAPP1DIR">
<iis:WebApplication Id="WebApp1IISApplication" Name="webapp1" />
</iis:WebVirtualDir>
</Component>
<Component Id="IIS_WebApp2" Guid="some-guid-2" Directory="wwwrootdir" KeyPath="yes">
<iis:WebVirtualDir Id="WebApp2VirtualDir" Alias="webapp2" WebSite="DefaultWebSite" Directory="WEBAPP2DIR">
<iis:WebApplication Id="WebApp2IISApplication" Name="webapp2" />
</iis:WebVirtualDir>
</Component>
<Component Id="IIS_WebApp3" Guid="some-guid-3" Directory="wwwrootdir" KeyPath="yes">
<iis:WebVirtualDir Id="WebApp3VirtualDir" Alias="webapp3" WebSite="DefaultWebSite" Directory="WEBAPP3DIR">
<iis:WebApplication Id="WebApp3IISApplication" Name="webapp3" />
</iis:WebVirtualDir>
</Component>
</ComponentGroup>
<ComponentGroup Id="IIS_Feature2">
<Component Id="IIS_WebApp4" Guid="some-guid-4" Directory="wwwrootcustom" KeyPath="yes">
<iis:WebSite Id="WebApp4Site" Description="Web App 4 Site" Directory="wwwrootcustom" AutoStart="yes">
<iis:WebVirtualDir Id="WebApp4VirtualDir" Alias="webapp4" Directory="WEBAPP4DIR">
<iis:WebApplication Id="WebApp4IISApplication" Name="webapp4" />
</iis:WebVirtualDir>
<iis:WebAddress Id="WebApp4SiteAddr" Secure="yes" Port="443"/>
</iis:WebSite>
</Component>
</ComponentGroup>
This issue was discovered during early development of my installer. As more development work was done and other issues resolved, I am no longer seeing this behavior.
I never really figured out exactly what was happening, but I have noticed during testing if one or more things are awry with the installer, certain (seemingly unrelated) components will be left behind during the uninstall...

Using WiX, how do I change a property of a subfolder of a virtual directory?

I have a hierarchy of Directory elements in a WiX script.
I also have a component that creates a virtual directory (using IIS:WebVirtualDir), which points to the root of my Directory hierarchy.
How do I change a property (e.g. AnonymousAccess) of a subfolder of the virtual directory, e.g.
MyVirtualDir <<< this is the virtual directory root
MyVirtualDir\MySubFolder <<< this is the subfolder for which I wish to change a property using WebDirProperties
Please note that I do not wish to create a new virtual directory for the subfolder. I only wish to change a few security settings.
The current script is too big to post here, but take a look at the WiX tutorial: 5.3 Web Directory. Suppose in that example that there was another Directory element named "MySubFolder" nested within the "InstallDir" element. What would then be the next step in order to set properties for "MySubFolder" without turning it into a virtual directory?
Sample code for the IIS:Web element seems to be hard to come by, but after some trial and error, I think I found a solution:
Create the folder as normal in the Directory hierarchy:
<Directory Id='blahDir' Name='blah'>
<Component Id ='CreateBlah' Guid='B1976E1A-DEB1-4FBB-A5AB-4AA60930D2DC'>
<CreateFolder />
</Component>
</Directory>
Create an IIS:WebDirProperties element (in this case, some random values for testing):
<IIS:WebDirProperties Id="ReadAndExecute" Read="yes" Write="yes" Script="yes" Execute="yes" AnonymousAccess="yes" Index="no" LogVisits="no" />
Create an IIS:WebDir component pointing to the folder and the WebDirProperties element:
<Component Id='TestWebDir' Guid='8ED05357-1AAE-49F2-8C66-8813583C8157'>
<IIS:WebDir WebSite='DefaultWebSite' Id='MyWebDir' Path='Test/blah' DirProperties='ReadAndExecute' />
</Component>
The entire sample, adapted from the WiX tutorial, can be found below:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:IIS="http://schemas.microsoft.com/wix/IIsExtension">
<Product Name='Foobar 1.0' Id='48A3DF7A-E1C3-48BE-91D9-4D7368740A78' UpgradeCode='F8ABBBC9-0696-4FA9-A0DC-C9368E858A76'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Acme Ltd.'>
<Package Id='*' Keywords='Installer'
Description="Acme's Foobar 1.0 Installer"
Comments='Foobar is a registered trademark of Acme Ltd.' Manufacturer='Acme Ltd.'
InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
<Icon Id="AddRemoveProgram.ico" SourceFile="AddRemoveProgram.ico" />
<Property Id="ARPPRODUCTICON" Value="AddRemoveProgram.ico" />
<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='InstallDir' Name='Acme'>
<Directory Id='blahDir' Name='blah'>
<Component Id ='CreateBlah' Guid='B1976E1A-DEB1-4FBB-A5AB-4AA60930D2DC'>
<CreateFolder />
</Component>
</Directory>
<Component Id='default.htmlComponent' Guid='E2FC2FC2-96A2-4BE5-BBCB-7184D9AAACA0'>
<File Id='default.htmFile' Name='default.htm' KeyPath='yes' DiskId='1' Source='default.htm' />
</Component>
</Directory>
</Directory>
<Component Id='TestWebVirtualDirComponent' Guid='B4E73F80-875C-487A-BC57-A568732F03A3'>
<IIS:WebVirtualDir Id='TestWebVirtualDir' Alias='Test' Directory='InstallDir' WebSite='DefaultWebSite'>
<IIS:WebApplication Id='TestWebApplication' Name='Test' />
</IIS:WebVirtualDir>
</Component>
<Component Id='TestWebDir' Guid='8ED05357-1AAE-49F2-8C66-8813583C8157'>
<IIS:WebDir WebSite='DefaultWebSite' Id='MyWebDir' Path='Test/blah' DirProperties='ReadAndExecute' />
</Component>
</Directory>
<IIS:WebSite Id='DefaultWebSite' Description='Default Web Site'>
<IIS:WebAddress Id='AllUnassigned' Port='80' />
</IIS:WebSite>
<Feature Id='TestFeature' Title='TestFeature' Level='1'>
<ComponentRef Id='CreateBlah'/>
<ComponentRef Id='default.htmlComponent' />
<ComponentRef Id='TestWebDir'/>
<ComponentRef Id='TestWebVirtualDirComponent' />
</Feature>
<IIS:WebDirProperties Id="ReadAndExecute" Read="yes" Write="yes" Script="yes" Execute="yes" AnonymousAccess="yes" Index="no" LogVisits="no" />
</Product>
</Wix>

Resources