WiX and iis (cannot connect to internet information server) - iis

I try to create installer, where web site is creates too.
I use the following code
....
<DirectoryRef Id="WEBFOLDER">
<Component Id="WebLibraries" Guid="77532F98-BF0B-4b9d-98AF-15618691A090" KeyPath="yes">
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site" Directory="WEBFOLDER">
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
</Component>
</DirectoryRef>
....
<Feature Id="WebSite" Level="1" Title="Web site">
<ComponentRef Id="WebLibraries" />
</Feature>
....
but when i try to install a created package on machine where iis is not installed, i have got this message even i don't check this feature:
cannot connect to internet information server
Can anybody help me with this trouble?
Thanks in advance.

You're installing your package on a machine where IIS is not installed. What would you expect? :)
To be serious, the WiX IIsExtension (the one which defines WebSite element) uses the API of IIS component to actually do its job. For WiX v3.0 it even requires IIS 6 compatibility to be turned ON in IIS 7 in order to work correctly.
Your component, which contains WebSite element, is not conditioned. this means it will always be installed. When it is installed, the IIsExtension tries to create a website defined in it (if we tell this story short).
So, I would recommend you to do the following (if you wish just skip the IIS part of your installer on target machines like that):
add a launch condition to check if the IIS component is installed (you can rely on IISMAJORVERSION property defined by IIsExtension itself)
condition your component (or feature) which is dependent on IIS with "NOT IISMAJORVERSION" condition
As a result, when IISMAJORVERSION property is not set (IIS is not installed), your component will not be scheduled for install and the IIS custom actions won't run.
P.S. The SKIPCONFIGUREIIS property I initially meant is "all-or-nothing" switch, and is not an appropriate tool for your case.

Related

How to create an IIS7 Virtual Directory Under Another Website (Not the Default Website) Using WiX

I am really struggling to create a Virtual Directory in an existing website in IIS7 using WiX.
To illustrate, what I therefore have are:
1) The IIS Default Website, and
2) Another website which is a container for a number of business applications and we can call "ContainerWebsite".
What I therefore desperately wish to do is create the following using WiX:
a) Create a virtual directory for one of the business applications (let's call it "BusinessApp1") under "ContainerWebsite". The final structure in IIS will therefore look like this "ContainerWebiste\BusinessApp1"
Should the above virtual directory be successful, I intend to create similar virtual directories for the remaining business applications.
b) Create a dedicated IIS Application Pool for each of the business applications installed to the "ContainerWebsite".
I would be extremely grateful for any assistance towards achieving thie.
Thank you.
See http://blog.torresdal.net/2008/10/24/#WebSiteStandardAction, where it goes into creating a custom action to list the existing websites and selecting one from a drop down. I suppose you can just skip the dropdown and specify the specific website to use, then reference it within your iis:WebVirtualDir section, like so:
<iis:WebSite Id="SelectedWebSite" Description="[WEBSITE_DESCRIPTION]">
<iis:WebAddress Id="AllUnassigned" Port="[WEBSITE_PORT]" IP="[WEBSITE_IP]" Header="[WEBSITE_HEADER]" />
</iis:WebSite>
<iis:WebVirtualDir Id="VirtualDir" Alias="[TARGETVDIR]" Directory="INSTALLLOCATION" WebSite="SelectedWebSite">
<iis:WebApplication Id="SimpleWebAppApp" Name="[TARGETVDIR]" WebAppPool="SWAAppPool" />
<iis:WebDirProperties Id="WebVirtualDirProperties" Execute="yes" Script="yes" Read="yes" WindowsAuthentication="no" AnonymousAccess="yes" IIsControlledPassword="yes" />
</iis:WebVirtualDir>

WIX Web Project installer removes manually added virtual directory

We have a project web installer that installs, upgrades etc. properly. The only issue is that on upgrade we have a problem with a virtual directory created inside the application manually via the IIS manager. We have some statically linked files which can be installed in different ways, if using a cluster it makes more sense to throw them on a network file share/DFS rather than copy them individually (they are very large).
Is there a way that I can have the Wix Web project installer not remove manually created virtual directories inside our application on an upgrade? Or at least detect them and preserve them?
We are using a standard wix iis installation:
<!-- IIS website. Inside a Component, <WebSite> creates a new Web Site. Outside a Component, it's a look up. -->
<iis:WebSite Id='WS.WebSite'
Description='[WEBSITE]'
Directory='DI.InstallDirectory'>
</iis:WebSite>
<Component Id="CO.VirtualDirectory"
Guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
KeyPath="yes">
<!-- The WebSite attribute ties to a <WebSite> element in the setup file -->
<iis:WebVirtualDir Id="VD.VirtualDirectory"
Alias="[VIRTUALDIRECTORY]"
Directory="DI.InstallDirectory"
WebSite="WS.WebSite" >
<iis:WebDirProperties Id="WP.WebDirProperties" DefaultDocuments="overview.aspx" />
<!-- Turn the Virtual Directory into a web application. -->
<iis:WebApplication Id="WA.WebApplication"
Name="xxx"
WebAppPool="AP.ApplicationPool" />
</iis:WebVirtualDir>
<!-- This is pretty important. If the CreateFolder isn't there the WebVirtualDir won't get created as there are no files in this component.
http://www.mail-archive.com/wix-users#lists.sourceforge.net/msg03483.html -->
<CreateFolder />
</Component>

WiX: Installer always changes AppPool to enable 32bit app

WiX installer installs silverlight web application. It can work under 32 or 64 bit app pool. But when installation completed I see that selected app pool always set to Enable 32-bit applications.It is even for 64-bit pools. It is not sutiable because it can change existing pool for previously installed 64 applications.
I do not change explicitely this parameter. What is the reason of problem may be?
The code sample added:
<Component Id="WebAppVDirComponent"
Guid="C7A4B0E8-2389-4A2A-B285-96960BEE1C52" KeyPath="yes">
<Condition><![CDATA[RBGROUP_HOSTING = "iis"]]></Condition>
<iis:WebVirtualDir Id="VDir"
Alias="[WEB_APP_NAME]"
Directory="INSTALLDIR"
WebSite="TheWebSite" >
<iis:MimeMap Id="SilverlightMimeType" Extension=".xap" Type="application/x-silverlight-app" />
<iis:WebApplication Id="WorkWebApplication"
Name="[WEB_APP_NAME]" WebAppPool="TheAppPool"/>
</iis:WebVirtualDir>
<iis:WebAppPool Id="TheAppPool" Name="[APP_POOL_NAME]" ></iis:WebAppPool>
<CreateFolder/>
</Component>
This had been designed in a very elegant way, in my opinion.
If you place the <iis:WebAppPool> element declaration to the <Component> marked as Win64="yes", the application pool will be created with Enable32bit flag set to false. Otherwise (that is, by default), it will be created with Enable32bit set to true.
I'm not sure how it will behave when you don't create the application pool with your installation, but reference the existing one instead. I would expect it not to change this flag at all. You can experiment with this to find out how it works exactly.
And a side note: I would avoid installing to the existing application pool or website. This is far more difficult to maintain - remember that you must leave the machine in its "pre-install" state after uninstallation. This means you'll have to maintain backup/restore the state of everything you change with custom actions... Brrr...

Config Error: This configuration section cannot be used at this path

I've encountered an error deploying a site to a server. When trying to load the home page, or access authentication on the new site in IIS, I get the error:
Config Error: This configuration section cannot be used at this path.
This happens when the section is locked at a parent level. Locking is
either by default (overrideModeDefault="Deny"), or set explicitly by a
location tag with overrideMode="Deny" or the legacy
allowOverride="false".
More detail can be found here, in Scenario 7 matches my hex error code.
The solution given on the linked site above is to set Allow for overrideModeDefault in the section mentioned in my error, in the applicationHost.config file. In my case, under Security in system.webServer. But if I look at the applicationHost.config on my local computer, where the site is properly deployed already, that section is set to Deny.
If this solution is correct, how is my local instance running just fine with the same web.config? According to my applicationHost.config, that section should be locked, but it's not. I'd prefer to not change the applicationHost.config file, because there are many other sites running on that server. Is there another solution?
I had the same problem. Don't remember where I found it on the web, but here is what I did:
Click "Start button"
in the search box, enter "Turn windows features on or off"
in the features window, Click: "Internet Information Services"
Click: "World Wide Web Services"
Click: "Application Development Features"
Check (enable) the features. I checked all but CGI.
btw, I'm using Windows 7. Many comments over the years have certified this works all the way up to Windows 10 and Server 2019, as well.
You could also use the IIS Manager to edit those settings.
Care of this Learn IIS article:
Using the Feature Delegation from the root of IIS:
You can then control each of machine-level read/write permissions, which will otherwise give you the overrideMode="Deny" errors.
For Windows Server 2012 and IIS 8, the procedure is similar.
The Web Server (IIS) and Application Server should be installed, and you should also have the optional Web Server (IIS) Support under Application Server.
Browse to “C:\Windows\System32\inetsrv\config” (you will need administrator rights here)
Open applicationHost.config
Note: In IISExpress and Visual Studio 2015 the applicationHost.config is stored in $(solutionDir).vs\config\applicationhost.config
Find the section that showed up in the “config source” part of the error message page. For me this has typically been “modules” or “handlers”
Change the overrideModeDefault attribute to be Allow
So the whole line now looks like:
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
After saving the file, the page loaded up fine in my browser.
Warning:
Editing applicationHost.config on 64-bit Windows
You need to unlock handlers. This can be done using following cmd command:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
Maybe another info for people that are getting this error on IIS 8, in my case was on Microsoft Server 2012 platform. I had spend couple of hours battling with other errors that bubbled up after executing appcmd. In the end I was able to fix it by removing Web Server Role and installing it again.
1. Open "Turn windows features on or off" by: WinKey+ R => "optionalfeatures" => OK
Enable those features under "Application Development Features"
Tested on Win 10 - But probably will work on other windows versions as well.
I ran these two commands from an elevated command prompt:
%windir%/system32/inetsrv/appcmd unlock config /section:anonymousAuthentication
%windir%/system32/inetsrv/appcmd unlock config /section:windowsAuthentication
As per my answer to this similar issue;
Try unlocking the relevant IIS configuration settings at server level, as follows:
Open IIS Manager
Select the server in the Connections pane
Open Configuration Editor in the main pane
In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
Click Unlock Attribute in the right pane
Repeat for any other settings which you need to unlock
Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
This Did the trick for me, for IIS 8 Windows server 2012 R2
Go to "Turn on Features"
Then go to all default setting , Next, Next, Next etc..
Then, select as shown below,
Then reset IIS (optional) but do it safer side.
This is an additional solution as its a generic problem everyone have different of problem and thus different solution. Cheers!
The best option is to Change Application Settings from the Custom Site Delegation
Open IIS and from the root select Feature Delegation and then select Application Settings and from the right sidebar select Read/Write
On Windows Server 2012 with IIS 8 I have solved this by enabling ASP.NET 4.5 feature:
and then following ken's answer.
To fix this open up the IIS Express applicationhost.config. This file is stored at C:\Users[your user name]\Documents\IISExpress\config\applicationhost.config
Update for VS2015+: config file location is $(solutionDir).vs\config\applicationhost.config
Look for the following lines
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
Change those lines to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
Save it and refresh Asp.net Page.
In our case on IIS 8 we found the error was produced when attempting to view Authentication" for a site, when:
The server Feature Delegation marked as "Authentication - Windows" = "Read Only"
The site had a web.config that explicitly referenced windows authentication; e.g.,
Marking the site Feature Delegation "Authentication - Windows" = "Read/Write", the error went away. It appears that, with the feature marked "Read Only", the web.config is not allowed to reference it at all even to disable it, as this apparently constitutes a write.
Seems that with IIS Express and VS 2015, there's a copy of the applicationHost.config file at $(solutionDir).vs\config\applicationhost.config so you'll need to make changes there. See this link: http://digitaldrummerj.me/iis-express-windows-authentication/
Make sure these lines are changed per below:
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
In my case it was that on server was not enabled "HTTP Activation" under .NET Framework Features. So for Windows Server 2012 the solution which worked for me was:
Server Manager -> Add roles and features -> Features -> make sure that under .NET Framework of version you want to use is checked "HTTP Activation"
The Powershell way of enabling the features (Windows Server 2012 +) - trim as needed:
Install-WindowsFeature NET-Framework-Core
Install-WindowsFeature Web-Server -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-45-ASPNET -IncludeAllSubFeature
Install-WindowsFeature Application-Server -IncludeAllSubFeature
Install-WindowsFeature MSMQ -IncludeAllSubFeature
Install-WindowsFeature WAS -IncludeAllSubFeature
The error says that the configuration section is locked at the parent level.
So it will not be directly 1 config file which will resolve the issue,
we need to go through the hierarchy of the config files to see the inheritance
Check the below link to go through the File hierarchy and inheritance in IIS
https://msdn.microsoft.com/en-us/library/ms178685.aspx
So you need to check for the app config settings in the below order
ApplicationHost.config in C:windows\system32\inetsrv\config. Change the overrideModeDefault attribute to be Allow.
ApplicationName.config or web.config in the applications directory
Web.config in the root directory.
Web.config in the specific website (My issue was found at this place).
Web.config of the root web (server's configuration)
machine.config of the machine (Root's web.config and machine.config can be found at - systemroot\MicrosoftNET\Framework\versionNumber\CONFIG\Machine.config)
Go carefully through all these configs in the order of 1 to 6 and you should find it.
I noticed one answer that was similar, but in my case I used the IIS Configured Editor to find the section I wanted to "unlock".
Then I copied the path and used it in my automation to unlock it prior to changing the sections I wanted to edit.
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/windowsAuthentication
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/anonymousAuthentication
I needed to change the SSL settings on a subfolder when i got this nice message. In my case following action helped me out.
Opened C:\Windows\System32\inetsrv\config\applicationHost.config
And changed the value from overrideModeDefault="Deny" to "Allow"
<sectionGroup name="system.webServer">
...
<sectionGroup name="security">
<section name="access" overrideModeDefault="Allow" />
</sectionGroup>
In my case, I got this error because I was operating on the wrong configuration file.
I was doing this:
Configuration config = serverManager.GetWebConfiguration(websiteName);
ConfigurationSection serverRuntimeSection = config.GetSection("system.webServer/serverRuntime");
serverRuntimeSection["alternateHostName"] = hostname;
instead of the correct code:
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection serverRuntimeSection = configApp.GetSection("system.webServer/serverRuntime", websiteName);
serverRuntimeSection["alternateHostName"] = hostname;
in other words, I was trying to operate on the website's web.config instead of the global file C:\Windows\System32\inetsrv\config\applicationHost.config, which has a section (or can have a section) for the website. The setting I was trying to change exists only in the applicationHost.config file.
In my case, it was something else.
When I loaded the solution in a new version of Visual Studio, VS apparently created a new project-specific applicationhost.config file:
MySolutionDir\.vs\config\applicationhost.config
It started using the settings from the new config, instead of my already customized global IIS Express settings.
(\Users\%USER%\Documents\IISExpress\config\applicationhost.config)
In my case this was the setting that needed to be set. Of course it could be something else for you:
<section name="ipSecurity" overrideModeDefault="Allow" />
Received this same issue after installing IIS 7 on Vista Home Premium. To correct error I changed the following values located in the applicationHost.config file located in Windows\system32\inetsrv.
Change all of the following values located in section -->
<div mce_keep="true"><section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
<div mce_keep="true"><section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
Can You try this:
Go to application path where you're getting deny error, right click
Properties->Security tab
In that, change the permissions and check the checkbox read and write. Then it will work without any error hopefully.
For Windows Server 2008 and IIS 7, the procedure is similar.
please refer to this:
http://msdn.microsoft.com/en-us/library/vstudio/bb763178(v=vs.100).aspx
in add role service, u will see "Application Development Features"
Check (enable) the features. I checked all.
In my case I was getting this error when attempting to update the authentication settings in IIS also in addition to browsing. I was able to remove this error by removing the authentication setting from the web.config itself. Removing a problematic configuration section may be less invasive and preferable in some cases than changing the server roles and features too much:
Section Removed:
<security>
<authentication>
<windowsAuthentication enabled="true" />
</authentication>
</security>
I had the similar issue, but I used the following powershell script which helped me to achieve above steps in on button click.
#Install IIS
Import-Module ServerManager
Add-WindowsFeature Web-Server, Web-Asp-Net45, Web-Mgmt-Console, Web-Scripting-Tools, NET-WCF-HTTP-Activation45, Web-Windows-Auth
the list of features can be added or removed based on the requirement.
I had an issue where I was putting in the override = "Allow" values (mentioned here already)......but on a x64 bit system.......my 32 notepad++ was phantom saving them. Switching to Notepad (which is a 64bit application on a x64 bit O/S) allowed me to save the settings.
See :
http://dpotter.net/technical/2009/11/editing-applicationhostconfig-on-64-bit-windows/
The relevant text:
One of the problems I’m running down required that I view and possibly edit applicationHost.config. This file is located at %SystemRoot%\System32\inetsrv\config. Seems simple enough. I was able to find it from the command line easily, but when I went to load it in my favorite editor (Notepad++) I got a file not found error. Turns out that the System32 folder is redirected for 32-bit applications to SysWOW64. There appears to be no way to view the System32 folder using a 32-bit app. Go figure.
Fortunately, 64-bit versions of Windows ship with a 64-bit version of Notepad. As much as I dislike it, at least it works.
I had the same issue.
Resolved it by enabling Application Server feature. Restarted iis
after that.
This worked for me
Also in IIS 8 you can solve this problem by changing the server to IIS Express. Goto debug->Properties
In the Web select the server as IIS Express from the dropdown and then rebuild the solution
To make a change at Application Level (Web.Config):
Please remove the Trust Level from the web.config:
Actually I was getting this error when I was trying to host my Website on the Hosting Server where I don't have control on their Server. Removing the above line from my Application web.config solved my issue.

How can I disable the WebSite action in Wix when no web features are selected?

The Wix WebSite action has to be specified outside of a Component if you want to safely use the Default Web Site (by safely I mean the installer won't remove the default site on uninstall).
<Fragment>
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site" Directory="INSTALLDIR">
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
</Fragment>
My installer has a bunch of Features, and some are only enabled when IIS is installed. Disabling the features based on Conditions works fine, and no virtual directories or sites are created, but during install MSI still tries to contact IIS due to the WebSite action and fails on a machine without IIS installed:
"Cannot connect to Internet Information Server. (-2137221164 )"
I found something about SKIPCONFIGUREIIS but this doesn't seem to work in Wix 3.
This saved me from a lot of grief! Just wanted to add that the above will skip IIS configuration on uninstall regardless of installation state. I.E. if the feature was installed the virtual directory will not be removed from IIS on uninstall.
This seems to work for me:
<InstallExecuteSequence>
<!-- Disable ConfigureIIS if we don't need it: -->
<Custom Action="ConfigureIIs" After="InstallFiles"><![CDATA[&Web=3 OR !Web=3]]></Custom>
</InstallExecuteSequence>
I managed to solve this in Wix 3 using the Custom Action Conditions support in InstallExecuteSequence. This example assumes the feature "Web" is the only one that requires we perform IIS actions:
<InstallExecuteSequence>
<!-- Disable ConfigureIIS if we don't need it: -->
<Custom Action="ConfigureIIs" After="InstallFiles">(&Web = 3)</Custom>
</InstallExecuteSequence>
I just looked and found, in a WIX-generated MSI, the condition NOT SKIPCONFIGUREIIS AND VersionNT > 400 associated to the ConfigureIis row in the InstallExecuteSequence table.
In other words you could also use a Custom action like this:
<InstallExecuteSequence>
<!-- Disable the ConfigureIIs action if we don't need it: -->
<Custom Action="CA.SkipConfigureIIs"
After="InstallFiles">NOT &F.IisFeature = 3</Custom>
</InstallExecuteSequence>
<CustomAction Id="CA.SkipConfigureIIs"
Property="SKIPCONFIGUREIIS"
Value="1"
Return="check" />

Resources