Convert Virtual Directory to Web Application in WiX - iis

I am creating a new WebSite whenever Feature A or B is installed:
<Component Id="IIS.HelloWorld" Guid="6FA5EF90-C9D9-463C-9CC7-0410670AFBD1" Directory="TARGETDIR">
<iis:WebSite Id="IIS.HelloWorld" Description="Hello World for Web" Directory="INSTALLDIR">
<iis:WebAddress Id="HelloWorldAddress" IP="*" Port="8080"/>
</iis:WebSite>
</Component>
The WebSite is pointed to the INSTALLDIR (Say C:\MyFiles). Below the INSTALLDIR, I have 2 additional folders: Service (C:\MyFiles\Service) and Web (C:\MyFiles\Web)
Since the WebSite is pointed to INSTALLDIR, all sub-directories (Service and Web) were automatically treated as Virtual Directories (?) -- I can see them linked via IIS Management Console and I can access them via my browser.
However, they need to be "converted" to Applications (done manually by right-clicking the Virtual Directory and selecting "Convert to Application) in order for them to work properly (they contain ASPX and ASMX files).
So I've added the following component to try to convert them to "Applications":
<Component Id="IIS.HelloWorld.WebSite.VirtualDirectory" Guid="GUID-44D1-48D9-BB3C-4B0126FB83E5" Directory="TARGETDIR">
<iis:WebVirtualDir Id="IIS.HelloWorld.WebSite.VirtualDirectory" Alias="Service" Directory="INSTALLDIR.WebSite" WebSite="IIS.HelloWorld">
<iis:WebApplication Id="IIS.HelloWorld.WebSite.VirtualDirectory" Name="Service"/>
</iis:WebVirtualDir>
</Component>
But the Virtual Directories wasn't converted to "Applications"; they are still just virtual directories.
Question: How do I convert virtual directories to applications in WiX? Or what is the proper way to handle this situation?
Thanks!

My bad. I was binding the wrong Virtual Directory Alias to the wrong Web Application Name.
This code works:
<Component Id="IIS.HelloWorld.WebSite.VirtualDirectory" Guid="GUID-44D1-48D9-BB3C-4B0126FB83E5" Directory="TARGETDIR">
<iis:WebVirtualDir Id="IIS.HelloWorld.WebSite.VirtualDirectory" Alias="Web" Directory="INSTALLDIR.WebSite" WebSite="IIS.HelloWorld">
<iis:WebApplication Id="IIS.HelloWorld.WebSite.VirtualDirectory" Name="Web"/>
</iis:WebVirtualDir>
</Component>

Related

Can Web Deploy create IIS Site and Application Pool

I am working on automation of deployment process and I need to find a way to build and deploy an asp.net web site.
On top of this I would also like to create IIS Site and Application Pool for newly created IIS if one doesn't already exist.
Is this possible with Web Deploy (or is there an even better way/tool/approach to achieve these goals?)
Consider using ServerManager class from Miceosoft.Web.Administration namespace. Specifically, ApplicationPools and Sites properties.
For example,
ServerManager sm = new ServerManager();
Site site = serverMgr.Sites.Add(“MySiteName”, “C:\\inetpub\\wwwroot”, 8080);
sm.ApplicationPools.Add(“MyAppPool”);
sm.CommitChanges()
For more information see https://msdn.microsoft.com/en-us/library/microsoft.web.administration.servermanager(v=vs.90).aspx
Hope this helps.
There's also MSBuildExtensionPack:
https://github.com/mikefourie/MSBuildExtensionPack
I imagine that said msbuild-family-of-actions employs the Microsoft.Web.Administration namespace to work its magic in terms of creating a new website in IIS 7 and the scripting looks something like this (haven't tested this on my own server yet):
<Target Name="ProvisionIIS7WebSite" DependsOnTargets="CreateDeploymentNumber">
<PropertyGroup>
<WebSiteName>$(BaseDeploymentName)$(DeploymentNumber)</WebSiteName>
<PortNumber>$(DeploymentNumber)</PortNumber>
</PropertyGroup>
<ItemGroup>
<WebApplication Include="/MyApp">
<PhysicalPath>$(WebSitePath)</PhysicalPath>
</WebApplication>
<VirtualDirectory Include="/MyVdir">
<ApplicationPath>/MyApp</ApplicationPath>
<PhysicalPath>$(WebSitePath)</PhysicalPath>
</VirtualDirectory>
</ItemGroup>
<!-- Create new site -->
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Create"
Name="$(WebSiteName)"
Port="$(PortNumber)"
Path="$(WebSitePath)"
AppPool="$(WebSiteAppPool)"
Applications="#(WebApplication)"
VirtualDirectories="#(VirtualDirectory)">
<Output TaskParameter="SiteID" PropertyName="WebSiteID" />
</MSBuild.ExtensionPack.Web.Iis7Website>
<Message Text="Created website with ID $(WebSiteID)" />
</Target>

How to setup Multiple sites (Multi domain sites) in one Sitecore instance in My Local Machine?

I have been trying to configure multiple sites with multiple domain in my local instance.
Sitecore Content tree
Sitecore
-> Content
-> Home
-> PublicHome
I have the following web.config settings.
<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false"/>
<site name="PublicHome" hostName="my.public.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/PublicHome" language="en" database="web" domain="extranet" />
I have created couple of Host file entry.
127.0.0.1 My.Sitecore.com
127.0.0.1 my.public.com
My.Sitecore.com - Loading the Home Page.
But my.public.com is not loading as expected.
When binding was not setup in the IIS site. I was getting IIS Default site.
Once I add the binding on the IIS site. I was getting "Home" instead of "PublicHome".
Version info: Sitecore 7.5, IIS in Windows 10
To fix your immediate issue, add your custom site definition before the default "website" entry.
To better prepare yourself for future upgrades, utilize Sitecore patch attributes and a separate configuration file to apply your custom site definition. (i.e. <site name="PublicHome" patch:before="site[#name='website']">). Read about web.config patching to learn more.

Adding script maps during installation of web application IIS

has anyone successfully added IIS script maps to their Wix installation. I have been using this:
<CustomAction Id="AddHandlers_Cmd" Property="AddHandlers" Value=""[SystemFolder]inetsrv\appcmd" set config -section:system.webServer/handlers /+"[\[]name='GSOAP',path='*.dll', verb='*',modules='IsapiModule',scriptProcessor='[BIN]mod_gsoap.dll',resourceType='File', requireAccess='Execute'[\]]"" Execute="immediate"/>
<CustomAction Id="AddHandlers" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no"/>
However I get the 404 errors from my web application and when I add the script map manually after installing the application it works perfectly. I would appreciate if anyone could share how they done this.
It sounds like you need to add handler mapping to your web application. If that's the case, then you don't need a custom action to accomplish this.
Take a look at WebApplicationExtension element.
We are writing a separate Custom action in C# and Schedule it in after install Finalize to add handlers.
Try this, you can do anything with your own custom action.
I haven't worked with GSOAP handler, but used ASP.NET ISAPI extention. I suppose basically it has the same level of integration. I will post the code for ASP.NET and I hope you won't have problem with changing it to GSOAP. I have a huge risk of changing something incorrectly and make the examples unusable for you, so I let you do it better.
Here is my code to register extention itself if it isn't
<Component Id="Iis6ConfigExtentions" Guid="{GuidHash({ProductId}-1822E4F3-5850-47D5-9281-D1E0E20C77D4)}" KeyPath="yes" Permanent="yes">
<Condition><![CDATA[Installed OR (IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
<iis:WebServiceExtension Id="ExtensionASP4" Group="ASP.NET v4.0.30319" Allow="yes" File="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" Description="ASP.NET v4.0.30319"/>
</Component>
and for adding those to the concrete site you need to use WebApplicationExtention, as #Yan already mentioned:
<iis:WebApplication Id="IIS6WebApp" Name="[SITE_APP_NAME]" WebAppPool="AppPool" >
<iis:WebApplicationExtension Verbs="GET,HEAD,POST" CheckPath="no" Script="yes" Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" />
</iis:WebApplication>
The CheckPath="no" is required on IIS 6 because we use ASP.NET MVC which doesn't map urls to files on disk. You might need it too since service address probably doesn't map to physical file.
UPDATE:
Looks like it is really not possible to do it directly in WIX (at least in 3.5 version). You are going in right direction - custom action using appcmd. But the provided custom actions aren't complete or what you need: the first one just sets property value to the command you need to execute and the second one calls some Dll custom action which wasn't provided.
What I'd try to execute is:
<CustomAction Id="AddGsoapHandler" Directory="TARGETDIR" Impersonate="no" Execute="deferred" Return="check" ExeCommand="[SystemFolder]inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[\[]name='GSOAP',path='*.dll', verb='*',modules='IsapiModule',scriptProcessor='[BIN]mod_gsoap.dll',resourceType='File', requireAccess='Execute'[\]]" /commit:apphost" />
Please pay attention to the path attribute of your handler configuration. It will limit handler usage to only URL's which ends with ".dll" - I just copied it from your code but not sure if you've done it intentionally or just copied from example at Microsoft site. That might have led to 401 error even if handler is registered successfully.
Also I added the /commit:apphost argument. Not sure if you really need this, but I use it to explicitly specify that I need to configure my application's config.
UPDATE 2:
If you need to set configuration to only single application, you should specify application object as argument of appcmd instead of the 'config' which means global configuration. Please try this:
<CustomAction Id="AddGsoapHandler" Directory="TARGETDIR" Impersonate="no" Execute="deferred" Return="check" ExeCommand="[SystemFolder]inetsrv\appcmd.exe set app "MySite/app1" -section:system.webServer/handlers /+"[\[]name='GSOAP',path='*.dll', verb='*',modules='IsapiModule',scriptProcessor='[BIN]mod_gsoap.dll',resourceType='File', requireAccess='Execute'[\]]" /commit:apphost" />
For more details you can read this tutorial.

Creating Application pool in WIX Installer

I'm creating website with custom application pool settings using WIX. After installation my new website is using Default Application Pool instead of using the one that I'm creating during installation.
I could find ways for virtual directory to point to newly created app pool but seems iis:WebSite does not have attribute for setting app pool.
Here is my code:
<iis:WebSite Id="MyWebSite" Description='MyWebsiteDesc' SiteId='*' Directory='MyWebFolder'>
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<util:User Id="MyAppPoolUser"
CreateUser="no"
Name="[APPPOOL_USER]"
Password="[APPPOOL_PASS]"
Domain="." />
<iis:WebAppPool Id="MyAppPool"
Name="[WEB_APP_NAME]"
Identity="other"
User="MyAppPoolUser"
ManagedRuntimeVersion="v4.0"
ManagedPipelineMode="Integrated" />
Use IIS:WebVirtualDir/IIS:WebApplication to point to your AppPool.
Hope, this might help you.
You have created an application pool but you have only created a web site. To use the application pool, you must create a virtual directory or application within the website. Both the WebVirtualDir and WebApplication elements have a WebAppPool attribute that you can use to configure IIS to use the application pool you are creating.
I recently faced this issue. All my web application inside website were assigned new app pool I created but base website was having DefaultAppPool.
This is the trick to assign app pool to base website
<iis:WebAppPool Id="MyAppPool" Name="YourAppPoolName" Identity="applicationPoolIdentity" />
<iis:WebSite Id='MyWebSite' Description='Dummy' Directory='APPLICATIONFOLDER'>
<iis:WebApplication Id="AnyId" Name="Dummy" WebAppPool="MyAppPool" />
</iis:WebSite>

How to remove WebApplication on uninstall?

I install WCF service to IIS.
Installer creates Virtual dir and convert it to web application. Unintallation removes all but Web application name remains under IIS site. How to remove it? There is the code
<iis:WebVirtualDir Id="VDir"
Alias="[WEB_APP_NAME]"
Directory="INSTALLDIR"
WebSite="TheWebSite" >
<!--Turn the Virtual Directory into a web application.-->
<iis:WebApplication Id="TestWebApplication"
Name="[WEB_APP_NAME]"
WebAppPool="TheAppPool"/>
</iis:WebVirtualDir>
<iis:WebAppPool Id="TheAppPool" Name="[APP_POOL_NAME]"/>
Also, Web site code is outside of component to prevent removing defaultwebsite:
<iis:WebSite Id='TheWebSite' Description='[WEBSITE_NAME]' Directory='INSTALLDIR'>
<iis:WebAddress Id="AllUnassigned" IP="*" Port="80"/>
</iis:WebSite>
Please check whether SKIPCONFIGUREIIS property was not set. If not (property was set) application will not be deleted

Resources