Using Wix to generate an MSI - visual-studio-2012

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>.

Related

Wix MSI Installer:How to allow anonymous authentication when set to override="deny" in applicationHost.Config

I have a web application that we install via a Wix MSI project. The web.config includes the authentication nodes below. Everything installs correctly but after installation, I get the error message:
"The configuration section cannot be used at this path". This is due to the configuration locking in applicationHost.config .
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
How can I override the applicationHost.config settings during the installation? I do install required Windows Features during the install, but am I missing one?
This is the solution that worked for me, calling appcmd from a custom action, before InstallFinalize.
<CustomAction Id="UnlockAnonymousAuthentication"
Execute="deferred"
Impersonate="no"
Return="check"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:anonymousAuthentication" />
<CustomAction Id="UnlockBasicAuthentication"
Execute="deferred"
Impersonate="no"
Return="check"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:basicAuthentication" />
<CustomAction Id="UnlockWindowsAuthentication"
Execute="deferred"
Impersonate="no"
Return="check"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:windowsAuthentication" />
<InstallExecuteSequence>
<Custom Action="UnlockAnonymousAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
<Custom Action="UnlockBasicAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
<Custom Action="UnlockWindowsAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
</InstallExecuteSequence>
Hope this helps someone.
Here is currently a way to do this directly using the WiX IIS extension WebDirProperties element:
https://wixtoolset.org/documentation/manual/v3/xsd/iis/webdirproperties.html
Something similar to this should work. Notice the critical piece is the WebDirProperties
element that specifies the
AnonymousAccess="yes" BasicAuthentication="no" WindowsAuthentication="no" which modify
the IIS properties you are looking to change during installation.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension" >
<Fragment>
<!-- Install to default web site -->
<iis:WebSite Id="DefaultWebSite" Description='Default Web Site'>
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<!-- References the installation folder specified in the Product.wxs file under the INSTALLFOLDER -->
<DirectoryRef Id="WEB_INSTALLFOLDER">
<!-- Configure virtual dir -->
<Component Id="VirtualDirectoryComponent"
Guid="{INSERT-YOUR-OWN-GUID-2C27-427A-A7B1-DA4DBCC79117}"
KeyPath="yes" >
<iis:WebVirtualDir Id="VirtualDirectory"
Alias="[WEB_DIRECTORY_ALIAS]" Directory="WEB_INSTALLFOLDER"
WebSite="DefaultWebSite">
<iis:WebDirProperties Id="VirtualDirectoryProperties"
AnonymousAccess="yes" BasicAuthentication="no"
WindowsAuthentication="no" />
<iis:WebApplication
Id="MyWebApplication"
Name="MyWebApplication" />
</iis:WebVirtualDir>
</Component>
</DirectoryRef>
</Fragment>
</Wix>

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...

Wix Toolset copy file issue

I am new to wix and am havaingsome issues using the copyfile component in wix. Please can you loke at the code below and advise. Many Thanks in advanced.
I have 3 features, 3 componentgroups & 3 components as described below with the respective directoryRef
<Feature Id = "F1" Title "T1" Level ="1">
<ComponetGroupRef Id="CG1" />
<Condition Level="1">
<![CDATA[ComputerName="S1"]
</Condition>
</Feature>
<Feature Id = "F1" Title "T1" Level ="1">
<ComponetGroupRef Id="CG2" />
<Condition Level="1">
<![CDATA[ComputerName="S2"]
</Condition>
</Feature>
<Feature Id = "F1" Title "T1" Level ="1">
<ComponetGroupRef Id="CG3" />
<Condition Level="1">
<![CDATA[ComputerName="S3"]
</Condition>
</Feature>
<ComponentGroup id="CG1">
<ComponentRef id="c1" />
</ComponentGroup>
<ComponentGroup id="CG2">
<ComponentRef id="c2" />
</ComponentGroup>
<ComponentGroup id="CG3">
<ComponentRef id="c1" />
<ComponentRef id="c2" />
</ComponentGroup>
<DirectoryRef Id"ApplicationDirectory">
<Component Id="C1" Guid="xyz">
<File Id="F1"KeyPath="yes" Source="Some Source Location">
<CopyFile Id="CF1" DestinationDirectory="Dest1" />
</File>
</Component>
<Component Id="C2" Guid="abc">
<File Id="F2"KeyPath="yes" Source="Some Source Location">
<CopyFile Id="CF2" DestinationDirectory="Dest2" />
</File>
</Component>
</DirectoryRef>
so basically if I am running the wix msi on server S1 only File F1 should be copied, when I am running on server S2 only File F2 should be copied and when I am running on Server S3, Files F1 & F2 both should be copied.
The issue I am having is that all the files are being copied irrespictive or server name match.
Can you please advise if I am being foolish.
Thanks,
Janak
Wix is not for copy.
I defined a different wix template project for the work I wanted to do. So instead of copy from destination to another location. I changed the project implementation so that it copies from source to a different destination.

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