How do I add an Web Application to an existing Web Site? - wcf

How do I specy that there already is the IIS Default Web Site? The Default Web Site must not be uninstalled. I just want to add a new Web Application with my WiX installer.
Unfortunately I didn't find any fitting samples. Everyone always seems to install and uninstall the whole thing.
EDIT:
<Fragment>
<ComponentGroup Id="IIS">
<Component Id="EEE" Directory="WCFFOLDER">
<iis:WebVirtualDir Id="MyVirtualDir" Alias="MyVirtualDir" Directory="INSTALLDIR" WebSite="DEFAULTWEBSITE">
<iis:WebApplication Id="DeploymentWebAppl" Name="MyName" WebAppPool="MyAppPool" />
</iis:WebVirtualDir>
</Component>
</ComponentGroup>
<iis:WebSite Id="DEFAULTWEBSITE" Description="Default Web Site" Directory="INSTALLDIR">
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<iis:WebAppPool Id="MyAppPool" Name="MyAppPool"/>
</Fragment>
How do I specify that there also is an virtual directory? If I put the iis:WebApplication element directly into the Component I get the following error: "The Component element contains an unexpected child element 'iis:WebApplication"
What is the value of INSTALLDIR? I donÄt know where the Default Web SIte has its Directory (propably C:\intpub\wwwroot)
I want to do the same in my WiX installer as in the following C# code I have
using (ServerManager manager = new ServerManager())
{
var site = manager.Sites["Default Web Site"];
var application = site.Applications.CreateElement();
application.Path = "C:\ProgramFiles\.....";
application.EnabledProtocols = "http,net.tcp";
application.ApplicationPoolName = "MyAppPool";
site.Applications.Add(application);
manager.CommitChanges();
}

See the example code here: Install a New Virtual Directory to Default Web Site with WiX.
Rephrasing it: if you put your <iis:WebSite> element inside <Component> element, then the website is managed by MSI and removed when uninstalling. If not, then the website element is a placeholder, and it is not touched by uninstall.

Related

How can I optionally install IIS virtual directory with WiX Toolset?

I'm trying to optionally install a virtual directory if IIS is installed. If it's not installed, then just skip it.
I've got this check:
<Fragment>
<Property Id="IIS_MAJOR_VERSION">
<RegistrySearch Id="CheckIISVersion"
Root="HKLM"
Key="SOFTWARE\Microsoft\InetStp"
Name="MajorVersion"
Type="raw" />
</Property>
<iis:WebSite Id='DefaultWebSite' Description='Default Web Site' Directory='INSTALLFOLDER'>
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
</Fragment>
and based on the IIS_MAJOR_VERSION being present, I install the feature:
<Feature Id="ProductFeature2" Title="Setup" Level="1">
<ComponentRef Id="AppIIS" />
<Condition Level="0">NOT IIS_MAJOR_VERSION</Condition>
</Feature>
This part seems to work, however, the iis:WebSite node is causing issues. I only want to locate it if IIS_MAJOR_VERSION is present as well.
If I move the iis:WebSite node into the component group it works, but then iis:WebSite is not in 'locator' mode and gets installed and uninstalled (which is bad).
Is there a way I can conditionally run the check for iis:WebSite?
When you add any element from IIS extension (like <iis:WebSite>), a special custom action called ConfigureIIs is added to the InstallExecuteSequence table. This custom action is a so-called entry point to everything related to IIS management with the help of WiX IIS extension.
Fortunately, ConfigureIIs custom action is conditioned by default the way to skip it if need be. If you open the resulting MSI package with Orca and navigate to InstallExecuteSequence table on the left pane, you'll see the condition uses SKIPCONFIGUREIIS property. Thus, the idea is to set it to something (e.g. 1) in case you don't need to perform any IIS related activities.
It can be done with SetProperty element:
<SetProperty Id="SKIPCONFIGUREIIS" Value="1">NOT IIS_MAJOR_VERSION</SetProperty>

How to install global isapi filters with wix? (IIS 7.5)

I am struggling to install a com based isapi dll globally into iis 7.5 using wix 3.6.3303.1/4.0.12.0.
I have the following wix config (full config here):
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="IsapiDll" Guid="ADD-GUID-HERE">
<File Id="isapidll" Name="isapi.dll" Source="isapi.dll" />
</Component>
<Component Id="IisFilter" Guid="ADD-GUID-HERE">
<CreateFolder />
<iis:WebFilter Id="IisFilter" Name="MyIsapi" Path="[INSTALLFOLDER]isapi.dll" LoadOrder="last" Description="MyIsapi" />
</Component>
</ComponentGroup>
</Fragment>
I receive the following error in my msi log when running on Windows 7 32bit with IIS7.5:
WriteIIS7ConfigChanges: Error 0x8007000e: Failed while finding IAppHostElement filter/#name=(null)
WriteIIS7ConfigChanges: Error 0x8007000e: Failed to delete filter
WriteIIS7ConfigChanges: Error 0x8000ffff: Unexpected IIS Config action specified for global filter
WriteIIS7ConfigChanges: Error 0x8000ffff: Failed to configure IIS filter global.
WriteIIS7ConfigChanges: Error 0x8000ffff: WriteIIS7ConfigChanges Failed.
I fear the problem is a bug in wix itself.
CreateGlobalFilter() passes pwzFilterName to DeleteCollectionElement() before it has been assigned a value. This later causes Iis7FindAppHostElementString() to be called with a null wzAttributeValue value which appears to be the cause of the error.
I could of course be on a wild goose chase and be happy to be pointed in the right direction...
Update:
I've now played with website level installs and have that working with the addition of the WebSite attribute and element. Config here
Edit: Changed path attribute to correct format.
0x8007000e means out of memory and the (null) in the message makes me bet this is a bug in the custom action. If you can debug it that's ideal. In any case, entering a bug at http://wixtoolset.org/bugs would probably be a good idea.
You forgot to add WebSite attribute, this code works well for me in WIX3.7:
<Component Id="IsapiFilterComponent" Guid="AE102719-D7DE-450A-A44C-29E7D9A36C0D" KeyPath="yes">
<iis:WebFilter Id="MyWebDavFilter" Name="MyWebDavFilter" Path="[INSTALLFOLDER]MyWebDavFilter.dll" LoadOrder="last" Description="My Web Dav Filter" WebSite="DefaultWebSite" />
</Component>
but this
<Component Id="IsapiFilterComponent" Guid="AE102719-D7DE-450A-A44C-29E7D9A36C0D" KeyPath="yes">
<iis:WebFilter Id="MyWebDavFilter" Name="MyWebDavFilter" Path="INSTALLFOLDER]MyWebDavFilter.dll" LoadOrder="last" Description="My Web Dav Filter"/>
</Component>
gives the same error you have.
Of course, you have to add <iis:WebSite> element to your wxs file.

Wix: Preventing a file from restoring by Windows Installer Service

We have a little situation here. We are writing an ini file at install-time using following code segment:
<Component Id="_CFG" Guid="{CADE766F-3AF0-40A6-9D35-12AC4FD5B278}" Feature="DefaultFeature" KeyPath="yes" Location="either" NeverOverwrite="yes">
<CreateFolder Directory="CFG" />
<Environment Id="SharedAppend" Name="Path" Value="[CommonFilesFolder]Company Shared\MyDir" Separator=";" Action="set" Part="last" Permanent="yes" System="yes" />
<IniFile Id="MyCFG.ini1" Action="addLine" Directory="CFG" Key="LOCAL_ROOT" Name="ata.ini" Section="ALIAS" Value="[CommonAppDataFolder]Company\MyDir" />
<IniFile Id="MyCFG.ini73" Action="addLine" Directory="CFG" Key="APPLICATIONS" Name="ata.ini" Section="GENERAL" Value="Product1;Product2;Product3;Product4;" />
<RegistryValue Id="Registry47asdf" Root="HKLM" Key="SOFTWARE\Company\MyProd" Name="LocalRoot" Value="[CommonAppDataFolder]Company\MyDir\" Type="string" />
</Component>
This installation is conducted by an Admin user. Now a 2nd user (Standard) modify this file via some application. After that when a 3rd user would logged in and launch the application, Windows Installer Progress Dialog appear and that would restore the file to original one.
I thought, "NeverOverwrite" would prevent this, but it didn’t worked.
I’m assuming that "NeverOverwrite" attribute may not be applicable on element.
Anyone have any idea how to prevent this file from restoring by Windows installer service?
Thanks a bunch..
Modification of an ini file should not trigger Windows Installer Resiliency. What happens is that a component will be reinstalled when its keypath (i.e. a certain file or registry entry) disappears.
So you need to figure out these things:
Which component installs the INI file? (I suppose it is not the component you show in your question, because that one only modifies INI files.)
What is the keypath of that component? (If it is not marked explicitly, wix will take the first file or registry entry in that component.)
Why is the keypath file or registry entry disappearing, thus triggering the reinstallation of that component?
Also, you might want to consider putting the ini file in its own component. This way, it will be its own keypath and it will only be reinstalled by the windows installer resiliency mechanism when it actually disappeared (and not when some other file or registry entry disappears.)

WiX3 - util:XmlFile element executes again when new user first uses a per-machine installation

i created WiX installer project for deploying my .net winform app on a customer machine. The app only scans documents and saves the images to database on a server. The scanner is quite specific and only one in the company, but there are approx. four users that can occasionaly use it => app will be installed just on a single workstation dedicated only for scanning - most of the time it will be free and any of these users can come, scan the docs and go continuing his work.
=> i am doing a per-machine installation: ALLUSERS is hardcoded to 1.
Because the database servers in production are not controlled by me and i do not really know, where the database will be stored, i can not pack correct ConnectionStrings.config file to the MSI archive. Instead of it the setup modifies this config according to parameter values provided by the user during install. For updating the connection strings I use util:XmlFile element. The connectionstrings.config file is stored in installation directory together with app binaries.
Everything seemed to work fine, until I simulated two users using this per-machine installation. I have executed my wix setup project under my own account, the XML config file had been correctly updated and then I launched the application and tested the connection strings are ok. Everything was fine.
Then I switched to another user account. The shortcut was already present in the program menu - just as I would have expected since the installation is per-machine. So I clicked the shortcut and then (unexpectedly for me) a progress bar window "Wait until the configuration of product XY is finished." appeared. (Note that my machine locale is not english, the message would probably be slightly different on an english locale workstation). After few seconds the window disappeared and my application launched. Unfortunately it was not able to connect to the database, since the connectionStrings.config file has been rewritten - the connection strings have been updated using default (=incorrect) property values.
I have been investigating why the setup launchs again whenever new user-account tries to use it. It is because of the shortcut element (Shortcut is placed to 'ProgramMenuFolder'. There is a request for uninstall action, which AFAIK requires a parent Component and this Component needs a KeyPath, which has to be a registry key under HKCU.). When I remove all the Program-Menu-Shortcut-stuff from WXS, MSI is not launched again after switching user context.
Result is that I have setup program, which is able to configure connection to a database according to input parameters. But any later attempt to use the app from a second user-account just sends this configuration down the toilette. In production environment this would mean, that an administrator has to come and manually change the connection strings every time new user tries to use the app, which is of course unacceptable behavior.
This is simplified version of my WiX source:
<?define ProductID = "11111111-1111-1111-1111-111111111111" ?>
<?define ProductName = "MyProduct" ?>
<?define ProductLocalName = "MyLocalLanguageProductName" ?>
<!-- application's root registry path, where it stores its settings -->
<?define ApplicationRootRegistryKey = "Software\MyCompany\MyProject\MyBuildConfiguration" ?>
<Product Id="$(var.ProductID)" UpgradeCode="{11111111-1111-1111-1111-111111111112}"
Name="$(var.ProductName)" Version="1.10.1103"
Manufacturer="MyCompany"Language="1029" Codepage="1250">
<Package Id="*" InstallerVersion="200" Compressed="yes"
Description="$(var.ProductName) Installer" Languages="1029"
SummaryCodepage="1250" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<!-- always install the app for all users -->
<Property Id="ALLUSERS" Value="1"/>
<!-- initialize properties used for adjusting connection strings.
The user will provide valid property values through command-line -->
<Property Id="DB_SERVER_NAME" Value="please-specify-db-server-name"/>
<Property Id="DB_NAME" Value="please-specify-db-name"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="CompanyProgramFilesFolder" Name="CompanyName" >
<Directory Id="INSTALLDIR" Name="ProjectName">
<Directory Id="InstallDirApp" Name="Bin" />
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="AppProgramMenuDir" Name="$(var.ProductLocalName)">
<Component Id="ProgramMenuDir" Guid="*">
<RemoveFolder Id='AppProgramMenuDir' On='uninstall'/>
<RegistryValue Root='HKCU' Key='$(var.ApplicationRootRegistryKey)' Type='string' Value='' KeyPath='yes' />
</Component>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="InstallDirApp">
<Component Id="Executable" Guid="*">
<File KeyPath="yes" Source="$(var.MyProject.TargetPath)">
<Shortcut Id="ProgramMenuShortcut" Name="$(var.ProductLocalName)"
Directory="AppProgramMenuDir" Advertise="yes"
WorkingDirectory="InstallDirApp" Icon="AppIcon.ico" IconIndex="0"/>
</File>
</Component>
<!-- ConnectionStrings config file deployment and settings adjustment -->
<Component Id="ConnectionStrings.config" Guid="*">
<File KeyPath="yes" Source="$(var.Csob.ChequesScanning.SmartShell.TargetDir)ConnectionStrings.config" />
<!--</Component>
<Component Id="xml01" Guid="*">-->
<!--<Condition><![CDATA[NOT Installed]]></Condition>-->
<!-- this sets the connection strings according to provided parameters -->
<util:XmlFile Id="SetConnectionString" Action="bulkSetValue"
File="[#ConnectionStrings.config]"
ElementPath="//add" Name="connectionString"
Value="Data Source=[DB_SERVER_NAME];Initial Catalog=[DB_NAME];Integrated Security=True;Pooling=True"
Permanent="yes" />
</Component>
</DirectoryRef>
<Icon Id="AppIcon.ico" SourceFile="$(var.MyProject.ProjectDir)Resources\AppIcon.ico" />
<Feature Id="ProductFeature" Title="MyProjectName" Level="1">
<ComponentRef Id="Executable" />
<ComponentRef Id="ConnectionStrings.config"/>
<ComponentRef Id="ProgramMenuDir" />
</Feature>
</Product>
</Wix>
I have tried these steps to resolve the problem, but nothing helped me:
1) I have separated the and the to independent components.
2) I Have Tried adding a NOT INstalled under these components.
3) I have tried writing a registry value to HKLM during installation. I have added a RegistrySearch and Property for that registry value and then used that value as a condition (in fact just a replacement of "NOT Installed" from the previous)
Can anyone help with this? What am I doing wrong?
Thanks in advice
Marek
Root your registry key under HKMU (See reference). This will correctly root your registry key in either HKLM or HKCU depending on the value of the ALLUSERS property.

Issue when creating an installer using wix to install in a specific website(NOT in Default Web Site)

I am creating an .msi using wix to install in "Test Web Site". But it always installs in "Default web site". The .wxs looks like:
<iis:WebSite Id='WebSiteId' Description="Test Web Site" Directory="Test_dir" >
<iis:WebAddress Id="TcpAddress" Port="80" />
</iis:WebSite>
<iis:WebVirtualDir Id="VirtualDir" Alias="TestService" Directory="Test_dir" WebSite="WebSiteId" >
<iis:WebApplication Id="TestWebApp" Name="TestService" />
</iis:WebVirtualDir>
Does anyone know how to install into "Test Web Site" (NOT in "Default Web Site")?
I found the solution for the problem I mentioned.
<iis:WebSite Id='WebSiteId' Description="Test Web Site" Directory="Test_dir" SiteId="*" >
<iis:WebAddress Id="TcpAddress" Port="80" />
</iis:WebSite>
When the attribute SiteId is set to *, then the website lookup is done using the Description attribute of the <iis:WebSite> element.