IIS websites

May 5, 2016 at 2:57 PM
I am using wixsharp to create websites in IIS...

The behavior I'd like to see (and I cannot seem to achieve) is a website that is made with the app pool I configure.

Right now a website is made with the default WebAppPool, and a virtual directory is added with said vdir using the app pool I configure for it...

I would really like to make an app pool for the actual site, otherwise I am dependent on having the default app pool at the target machine, which is out of my control
Coordinator
May 6, 2016 at 1:42 AM
The solution may be related to the Issue#113
new IISVirtualDir
{
    Name = "MyWebApp",
    AppName = "Test",
    WebSite = new WebSite("DefaultWebSite", "[IIS_SITE_ADDRESS]:[IIS_SITE_PORT]", "[IIS_SITE_NAME]"),
    WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
}
Does this help?
May 10, 2016 at 2:12 AM
Edited May 10, 2016 at 2:13 AM
kind of...the virtual directory is using that app pool, but the root website in where the virtual directory lives, is using the default app pool. I'd like the root website to also use that app pool.
Coordinator
May 10, 2016 at 3:09 AM
OK, then, honestly, it is beyond of my area of expertise. I know, it's not the answer you are looking for :)

If only you can tell me how raw WiX achieves this I would guide you through defining a Wix# equivalent. And if not supported I would implement it.
May 15, 2016 at 10:26 PM
I'm using the latest wixsharp package, WebSite constructor does not take three string arguments. When I remove the third argument I get this error:

...\bin\Release\WixSharpSetup.exe" "/MSBUILD:SetupWixSharpCustomUI"" exited with code -532459699. SetupWixSharpCustomUI

I haven't found a working IISVirtualDir example yet.
Coordinator
May 16, 2016 at 5:34 AM
> WebSite constructor does not take three string arguments.
My apologies. I typed the code sample incorrectly. It should be:
new IISVirtualDir
{
    Name = "MyWebApp",
    AppName = "Test",
    WebSite = new WebSite("[IIS_SITE_NAME]", "[IIS_SITE_ADDRESS]:[IIS_SITE_PORT]"),
    WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity")
}
> I haven't found a working IISVirtualDir example yet.
But did the sample from the distro work for you? I know your deployment requirements are a bit different but the sample from the distro supposed to work just out of box. And I would really prefer to know if it doesn't. Can you please confirm that "Wix# Samples\IIS\ASP.NETApp" sample works on your environment when it is compiled as it is.

As for the actual challenge you are facing, you have more chances to find some ideas (or even the solution) in the online resources associated with WiX specifically. After that encoding it in Wix# will be easy.

Thank you.
May 16, 2016 at 6:11 AM
I suspect my problem is that I'm using Files instead of File to add the 100's of files that building the web site publishes to the "AdminWebSitePublish" folder.

My IISVirtualDir isn't nested under an initial File.
                    , new Dir(@"AdminWeb\"
                        , new Files(featAdminWeb, @"..\Setup\AdminWebSitePublish\*.*")
                        , new IISVirtualDir
                        {
                            Name = "MyWebApp",
                            AppName = "Test",
                            WebSite = new WebSite("NewSite", "*:8080"),
                            WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                        }
                   )
It wasn't until I reorganized it like this:
                    , new Dir(@"AdminWeb\"
                        , new File(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\Global.asax"
                            , new IISVirtualDir
                            {
                                Name = "MyWebApp",
                                AppName = "Test",
                                WebSite = new WebSite("NewSite", "*:8080"),
                                WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                            }
                        )
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*", s => !s.EndsWith("Global.asax"))
                    )
That I could again build an installer.

It seems a bit arbitrary to pull out one of the files in the folder as a File just to nest the IISVirtualDir under it.
Is this close enough to the recommended way of doing things?
Coordinator
May 16, 2016 at 8:35 AM
> It seems a bit arbitrary to pull out one of the files in the folder as a File just to nest the IISVirtualDir
The reason for this are rather historical. The base code model that was used as a starting point was following a canonical ASL.NET deployment scenarion where VirtDir is a associated with the directory with at least a single file. Thus this file and its component/feature was used as a logical container for the virtual dir.

However you are right and strictly speaking VirtDir should be associated with the directory rather directly but not through the file.

I have updated the code and no the constructor takes the VirtDir
new Dir("MyWebApp",
         new IISVirtualDir
         {
             Alias = "MyWebApp2",
             AppName = "Test2",
             WebSite = new WebSite("My Web Site", "*:80") { InstallWebSite = true }
         },
Please test the NuGet package (v.1.0.34.2) with the changes.
May 16, 2016 at 1:41 PM
Edited May 16, 2016 at 1:42 PM
I think you meant 1.0.36.2.

Trying it now.

What does this mean in the "readme.txt" file that comes up following the install-package?
Because of the excessive size of the WiX Toolset the WixSharp.wix.bin NuGet package isn't a direct dependency of the WixSharp package and it needs to be added to the project explicitly:

Compiler.WixLocation = @"..\packages\WixSharp.wix.bin.<version>\bin";
May 16, 2016 at 2:02 PM
With the new structure I get no errors, but I also don't get a new web site...
Is there a problem now that the IISVirtualDir is not associated with a feature?

Here's the code and a bit of the install log file:
                    , new Dir(@"AdminWeb\"
                        , new IISVirtualDir
                        {
                            Name = "MyWebApp",
                            AppName = "Test",
                            WebSite = new WebSite("NewSite", "*:8080"),
                            WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                        }
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*")
                    )

Info: Cannot access session details from a non-immediate custom action
ActionStart: Action 8:56:46: StartIIS7ConfigTransaction. Starting IIS Config Transaction
ActionStart: Action 8:56:46: RollbackIIS7ConfigTransaction. Rolling back IIS Config Transaction
ActionStart: Action 8:56:46: CommitIIS7ConfigTransaction. Committing IIS Config Transaction
ActionStart: Action 8:56:46: ConfigureIIs7Exec. Configuring IIS
ActionStart: Action 8:56:46: WriteIIS7ConfigChanges. Installing Config Keys and Values
With the original structure. I get an error in the log on installation:
                    , new Dir(@"AdminWeb\"
                        , new File(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\Global.asax"
                            , new IISVirtualDir
                            {
                                Name = "MyWebApp",
                                AppName = "Test",
                                WebSite = new WebSite("NewSite", "*:8080"),
                                WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                            }
                        )
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*", s => !s.EndsWith("Global.asax"))
                    )


Info: Cannot access session details from a non-immediate custom action
ActionStart: Action 8:52:45: StartIIS7ConfigTransaction. Starting IIS Config Transaction
ActionStart: Action 8:52:46: RollbackIIS7ConfigTransaction. Rolling back IIS Config Transaction
ActionStart: Action 8:52:46: CommitIIS7ConfigTransaction. Committing IIS Config Transaction
ActionStart: Action 8:52:46: ConfigureIIs7Exec. Configuring IIS
ActionStart: Action 8:52:46: WriteIIS7ConfigChanges. Installing Config Keys and Values
Info: WriteIIS7ConfigChanges:  Error 0x80070002: Site not found for create application
Info: WriteIIS7ConfigChanges:  Error 0x80070002: Failed to configure IIS application.
Info: WriteIIS7ConfigChanges:  Error 0x80070002: WriteIIS7ConfigChanges Failed.
Info: CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Info: Action ended 08:52:46: InstallFinalize. Return value 3.
May 16, 2016 at 2:13 PM
Also tried new structure with the "InstallWebSite = true" property setting. No errors. No web site.
                    , new Dir(@"AdminWeb\"
                        , new IISVirtualDir
                        {
                            Name = "MyWebApp",
                            AppName = "Test",
                            WebSite = new WebSite("NewSite", "*:8080") { InstallWebSite = true },
                            WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                        }
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*")
                    )
May 16, 2016 at 2:23 PM
Went back and confirmed that with the old structure (IISVirtualDir under File) I do get a new web site with 1.0.36.
Coordinator
May 16, 2016 at 2:39 PM
> I think you meant 1.0.36.2.
Yes, you are correct. Txs.

> What does this mean in the "readme.txt" file that comes up following the install-package?
It means that your Wix# package doesn't install WiX and if you don't have it installed manually (from WiX website) then you need an additional NuGet package WixSharp.wix.bin. And then you also need to indicate where the WiX tools are:
Compiler.WixLocation = @"..\packages\WixSharp.wix.bin.<version>\bin";
> With the new structure I get no errors, but I also don't get a new web site...
May I ask you to do a little experiment for me. Can you please use the very ASP.NET setup sample from Git. This is the sample that uses new and old structure and on my machine it creates two web sites without any problems. I want to ensure that our environments behave the same way before we dive into more details.

https://wixsharp.codeplex.com/SourceControl/latest#src/WixSharp.Samples/Wix# Samples/IIS/ASP.NETApp/setup.cs
May 16, 2016 at 3:30 PM
Compiler.WixLocation
Hadn't realized it was a class static property setable in Main method. Obvious in hindsight :-)

Experiment...
I confirm that in my environment (built using Visual Studio 2015, starting with the WixSharp Setup project template, after install-package wixsharp -version 1.0.36.2),
I also see two new web sites ("My Web Site" and "My Web Site2") that will not start because they share a common port but otherwise look good (as requested).
May 16, 2016 at 4:21 PM
Going back to my project, NewSite3 gets installed in IIS along with Application Pool MyWebApp3, NewSite2 and MyWebApp2 do not.
                    , new Dir(@"AdminWeb2\"
                        , new IISVirtualDir
                        {
                            Name = "MyWebApp2",
                            AppName = "Test2",
                            WebSite = new WebSite("NewSite2", "*:8082") { InstallWebSite = true },
                            WebAppPool = new WebAppPool("MyWebApp2", "Identity=applicationPoolIdentity") 
                        }
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*")
                    )
                    , new Dir(@"AdminWeb3\"
                        , new File(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\Global.asax"
                            , new IISVirtualDir
                            {
                                Name = "MyWebApp3",
                                AppName = "Test3",
                                WebSite = new WebSite("NewSite3", "*:8082") { InstallWebSite = true },
                                WebAppPool = new WebAppPool("MyWebApp3", "Identity=applicationPoolIdentity") 
                            }
                        )
                        , new Files(featAdminWeb, @"..\SetupIPAV\AdminWebSitePublish\*.*", s => !s.EndsWith("Global.asax"))
                    )
I also tried modifying the sample code to look more like my project but could not get it to fail:
//css_dir ..\..\..\;
//css_ref WixSharp.dll;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
//css_ref System.Core.dll;
using System;
using System.Xml;
using System.Xml.Linq;
using System.Linq;
using WixSharp;
using WixSharp.CommonTasks;

class Script
{
    static public void Main(string[] args)
    {
        var myWebSite = new WebSite("My Web Site", "*:80")
        {
            //to be created instead of existing one to be reused
            InstallWebSite = true
        };
 
        var myFeature = new Feature("MYFEATURE", true);

        var project =
                new Project("My Product",
                    new Dir(@"%ProgramFiles%\MyCompany",
                        new Dir(@"MyWebApp"
                            , new IISVirtualDir
                            {
                                Name = "MyWebApp",
                                AppName = "Test",
                                WebSite = new WebSite("NewSite", "*:8080") { InstallWebSite = true },
                                WebAppPool = new WebAppPool("MyWebApp", "Identity=applicationPoolIdentity") 
                            },
                            /*
                            new IISVirtualDir
                            {
                                Alias = "MyWebApp2",
                                AppName = "Test2",
                                WebSite = new WebSite("My Web Site 2", "*:80") { InstallWebSite = true }
                            },
                            */
                            new Files(myFeature, @"MyWebApp\*.*")
                            )
                            )
                            );
 
        project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");
        project.UI = WUI.WixUI_ProgressOnly;
        project.OutFileName = "setup";
 
        project.PreserveTempFiles = true;
        project.BuildMsi();
    }
}
Coordinator
May 17, 2016 at 3:00 AM
OK, Then the sample works fine. It's a good starting point.

Now... I took the code from your last email. The top part code that fails to create "MyWebApp2". And I injected it into the code sample. I know you did practically the same but in this case I injected the code 100% identical to yours. The only difference is the file names (https://wixsharp.codeplex.com/SourceControl/latest#src/WixSharp.Samples/Wix# Samples/IIS/ASP.NETApp/setup.cs).

And... it seems to create all three web sites correctly.

Image

I actually liked your use case and made this change to the sample permanent and now it is in the code base. I also made the change to the ports so the all three apps use different ones. Txs.

Anyway, all this means that it looks like the problem is caused by some sort of conflict between what is being installed and the target IIS configuration. Or there is some little ambiguous bit in the generated WiX code that is upsetting the setup. If it is indeed WiX related then probably the best approach would be to investigate the generated wxs file. But of course you can just stick to what works (for whatever reason). I mean that nesting in the file.

As far as I can see your Wix# code has no problems whatsoever. I can only question that extra backspace in the dir name but I tested and it doesn't cause any problems anyway.

As for my concern about the health of the samples, I am satisfied now. :)

Thank you
May 17, 2016 at 3:18 AM
Since I have a working web site installer at this point I had to leave it as a bit of a mystery.

I'm now looking at my options for installing SQL Express 2012 as part of my installer...
It looks like you have plans for full Burn support in Wix# but there are issues with Wix that won't be fixed until Wix 4.0?

I've found bits and pieces, and suggestions that others have solved this (and a few suggestions from you that the goal might be beyond the scope of wix#).

Do you happen to know of a fleshed out working sample?
Coordinator
May 17, 2016 at 6:51 AM
Edited May 17, 2016 at 1:52 PM
As far as Wix# is concerned Burn is fully supported.

There is one outstanding WiX issue that indeed have a good chance to be fixed in WiX 4.0 though this issue in many cases is not a show stopper. May be I have already exchanged with you on this... Currently WiX fails to show an individual msi UI (when configured to do so) but only if this UI is implemented as an EmbeddedUI (this is the technology that Wix# ManagedUI relies on).

However having only bootstrapper default/custom UI or msi standard UI is not a problem at all. Having multiple packages (e.g. SQL Express) also can be done easy. There are ~4-5 samples that will help you: "Wix# Samples\Bootstrapper"

>I've found bits and pieces, and suggestions that others have solved this (and a few suggestions from you that the goal might be beyond the scope of wix#).
If you are talking about this very issue then I will be very interested in knowing any work around or even suggestion. At that time I couldn't find any but may be now there is something... I would rather have an ugly work around than to be on mercy of WiX releases schedule.