IIS website upgrade - iis

I'm building a website installer, during the installation phase I need to create an application pool and a website under IIS.
During the install / uninstall phases everything works fine: IIS is configured as expected.
Now I can't figure out how to obtain a decent user experience on upgrades: actually the setupkit overrides every configuration on the website (i.e. port bindings).
Is it possible to instruct Wix to not alter the website / application pool configuration during updates?
Here the code:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INETPUB" Name="Inetpub">
<Directory Id="INSTALLFOLDER" Name="MyWebSite">
<Component Id="MyWebSiteIssConfiguration" Guid="MY-GUID">
<Condition><![CDATA[NOT Installed]]></Condition>
<iis:WebAppPool Id="MyWebSiteAppPool"
Name="[APP_POOL_NAME]"
Identity="localService"
ManagedPipelineMode="Integrated"
ManagedRuntimeVersion="v4.0" />
<iis:WebSite Id="MyWebSiteWebsite" Description='[WEB_SITE_NAME]' Directory='INSTALLFOLDER' AutoStart='yes' StartOnInstall='yes'>
<iis:WebAddress Id="AllUnassigned" Port="[WEB_SITE_PORT]" />
<iis:WebApplication Id="MyWebSiteApplication" Name="[WEB_SITE_NAME][WEBSITE_ID]" WebAppPool="MyWebSiteAppPool"></iis:WebApplication>
<iis:WebDirProperties Id="MyWebSiteWebDirProperties" AnonymousAccess="no" WindowsAuthentication="yes" />
</iis:WebSite>
<CreateFolder/>
</Component>
</Directory>
</Directory>
</Directory>

In the end I've found a workaround that fits my needs.
First of all I've marked the component containing the website configuration (MyWebSiteIssConfiguration in my sample code) as Permanent='yes': this way the website is never uninstalled.
Also I've set ConfigureIfExists='no' on the website so during upgrade the configuration on the website is left untouched.

Related

WIX Installing App in new VirtDir links twice to new AppPool

Am trying to create a new WebApp, OPCClientWS, under an existing VirtDir, indx, under the root of the Default Web Site. The path will be /indx/OPCClientWS. This path actually does get created and is linked to a newly-created App Pool.
However, in the App Pool, I end up with an extra App reference: //indx/OPCClientWS. With this additional App reference in place, IIS will not start the website at all, throwing error 80070057:
The World Wide Web Publishing Service (WWW Service) did not register
the URL prefix http://*:80//indx/OPCClientWS for site 1. The URL may
be invalid. The site has been disabled. The data field contains the
error number.
Salient parts of the wxs code are as follows:
<Feature Id="ProductFeature" Title="OPCClientWS" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="AnSM_AppPoolInstall"/>
<ComponentRef Id="AnSM_WebDir"/>
</Feature>
Locating the root of the existing website, which already contains the indx Virtual Directory:
<Fragment>
<iis:WebSite Id="localhost_root" Description="Default Web Site">
<iis:WebAddress Id="localhost_addr" IP="AllUnassigned" Port="80"/>
</iis:WebSite>
</Fragment>
Creating the App Pool for the Application, set up in the next Fragment:
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="AnSM_AppPoolInstall" Guid="{8C762E41-A06F-49F9-8846-29CB148A446B}" KeyPath="yes">
<iis:WebAppPool Id="AnSM_AppPool" Name="AnSMAppPool" ManagedRuntimeVersion="v2.0" Identity="networkService"/>
</Component>
</DirectoryRef>
</Fragment>
Adding the WebVirtualDirectory to the existing Website:
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="AnSM_WebDir" Guid="{42A87FEB-BF0A-430D-8F23-3C4F8FE4E85F}" KeyPath="yes">
<CreateFolder/>
<iis:WebVirtualDir Id="OPCClient_VirtDir" Alias="indx/OPCClientWS" Directory="INSTALLFOLDER" WebSite="localhost_root">
<iis:WebApplication Id="AnSM_OPCWS" Name="OpcClientWS" WebAppPool="AnSM_AppPool"/>
<iis:WebDirProperties Id="AnSM_WebProps" AnonymousAccess="no" BasicAuthentication="no" WindowsAuthentication="yes"/>
</iis:WebVirtualDir>
</Component>
</DirectoryRef>
</Fragment>
And installing the various components into the directory (in Program Files), pointed to by the Virtual Directory:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="XHQAnSM" Name="Siemens AnSM">
<Directory Id="INSTALLFOLDER" Name="OPCClientWS">
<Directory Id="OPCClientWS.Content"/>
<Directory Id="OPCClientWS.Binaries" Name="bin"/>
<Directory Id="OPCClientWS.Symbols" Name="bin"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
Target platform is Windows 2008R2 64-bit, IIS 7.5 I have searched the web ad nauseum. Is there a way to debug what is being sent to IIS (e.g., using appcmd or similar)?
FWIW, I would submit this to wixtoolset, but their bug submission website seems to be hosed...
Digging into the applicationHost.config file (at C:\Windows\System32\inetsrv\config), I found that there was a stuck application, probably due to a previous failed installation. I suspect this might have been caused by a leading slash in the Alias of the iis:WebVirtualDir element.
Offending lines are:
<application path="//indx/OPCClientWS" applicationPool="AnSMAppPool">
<virtualDirectory path="/" physicalPath="C:\Program Files (x86)\Siemens AnSM\OPCClientWS" />
</application>
Shutting down IIS, removing the lines, and restarting fixed the problem.

Wix-Setting INSTALLDIR dynamically

I have created a web setup msi for installing a website to iis. In product.wxs I have set the directory to WWWROOT
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id="IISROOT" Name='WebDir'>
<Directory Id='INSTALLDIR' Name='MyWebSetup'></Directory>
</Directory>
</Directory>
During installation the user can provide desired name for virtual directory. If the user is entering any other name other than 'MyWebSetup' say 'MyWebSetup1', then in the IIS a virtual directory named 'MyWebSetup1' and a directory named 'MyWebSetup' gets listed. Now what I want is I need to get Name='MyWebSetup' with user entered name say 'MyWebSetup1'. I have tried using custom actions and many other to get this done, but was of no use. Please somebody can provide me with a very clear solution as I am new to Wix. Any helps appreciated.
Thank you.
I had a similar problem but with other folders under the [INSTALLDIR], BIN and Service folders.
Find the IIS root path in the registry
<Property Id="IISROOTPATH">
<RegistrySearch Id="FindIISRootPath" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
</Property>
Setting the directory value with SetDirectory which runs before CostFinalize in the execute sequence
<SetDirectory Id="INSTALLDIR" Sequence="execute" Value="[IISROOTPATH][VIRTUALDIR]">NOT Installed</SetDirectory>
<SetDirectory Id="SERVICEFOLDER" Sequence="execute" Value="[INSTALLDIR]\Services">NOT Installed</SetDirectory>
<SetDirectory Id="INSTALLDIRBIN" Sequence="execute" Value="[INSTALLDIR]\bin">NOT Installed</SetDirectory>
Then the directory structure
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISROOTPATH">
<Directory Id="INSTALLDIR" Name="MyWebSetup">
<Directory Id="INSTALLDIRBIN" Name="Bin">
<!-- BIN Dicrectory -->
</Directory>
<Directory Id="SERVICEFOLDER" Name="Services">
<!-- SERVICE FILES -->
</Directory>
</Directory>
</Directory>
</Directory>
Here is another similar question
I could solve this issue by passing the name of installdir with '.' and then using setdirectory to dynamically set the name of the installdir. While compiling, if the name is passed as '.' then the compiler just ignores it for the mean time and then if we pass the installdir name later then that name will be set.
The installdir name should be passed as follows
<Directory Id='INSTALLDIR'
Name='.'>
The setdirectory is passed as follows. [VIRTUALDIR] is the name of virtual directory accepted from user while installation.
<SetDirectory Id="INSTALLDIR" Sequence="execute" Value="[IISROOT][VIRTUALDIR]\">NOT Installed</SetDirectory>
Hope it helps somebody.

How to set proxy settings for IIS processes?

I have internet connection via http proxy, and some of my web applications at localhost need to access internet. Where can i set up proxy settings for them?
All I needed was to set system.net in web.config
<system.net>
<defaultProxy>
<proxy
proxyaddress="http://10.0.2.231:42"
bypassonlocal="true"
/>
</defaultProxy>
</system.net>
See: Element (Network Settings).

How do you get the default IIS Directory in a Wix install package?

I Would like to set my default install location in Wix to go the default IIS directory
usually C:\inetpub\wwwroot\
in the XML i have
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="myProduct">
I Assume i can change either the ProgramFilesFolder directory the the TARGETDIR to one that matches with an IIS property. (in case the default location is moved on a machine)
What would that be?
You can use a registry search to find the location:
<Property Id="INSTALLLOCATION">
<RegistrySearch Id="FindInetPubFolder" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
</Property>
But I would caution you that I don't typically do this. I tend to either create new websites or new virtual directories and use use ProgramFiles\Company\Product\WebSites\WebSite as where I put my files. This allows safer integration with whatever other web sites that might also exist on the box.

Can Intelligencia.UrlRewriter be made to work in IIS7?

We've inherited an application that uses the Intelligencia.UrlRewriter module. Our environment though is IIS7. We've already set our site to run in the classic asp.net application pool (which aparantly works for a lot of these kinds of problems). However we're still not seeing the URLs in our app be rewritten.
Has anyone run into this?
You need to define the config on the system.webServer element, like:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter"
type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</modules>
</system.webServer>
You can keep both config. What you probably have now is:
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</httpModules>
Check the section "Migrating ASP.NET Applications to IIS 7.0 Integrated mod" on http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/
ps. I have been using it with no trouble at all, as long as that config is in.
Update 1: Also check http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx, particularly "Approach 3: Using an HttpModule to Perform Extension-Less URL Rewriting with IIS7", since the config I added has the extension-less config.
Yes I had the exact same problem with Intelligencia.UrlRewriter module, running under Win Vista & IIS7, however switching to the classic asp.net app pool did fix the problem. Are you running the app in a new virtual directory? That can sometimes mess with the root path to the application which could make a difference to the rules in the web.config
I have spotted the same problem, after few tries I found out that changing asp mode to integrated pipeline helped.
Don't forget to add the following lines in the system.webServer section of your web.config file if you are using IIS7
<system.webServer>
<modules runAllManagedModulesForAllRequests=”true”>
<add name=”UrlRewriter” type=”Intelligencia.UrlRewriter.RewriterHttpModule” />
</modules>
<validation validateIntegratedModeConfiguration=”false” />
</system.webServer>
As in
http://frozengraphics.wordpress.com/2009/12/06/intelligencia-urlrewriter-and-iis7/

Resources