-1

I'm trying to add a web setup project for my web services project to make a reasonably complex installation easier for the end user. But the defaults are getting in my way and I'm not sure how to adjust them.

My requirements are:

  1. Create a new website & app pool
  2. When creating the new app pool, needs to be set to .Net 4, classic mode with user selectable user account to run the app pool
  3. Install the web service to a custom path under C:\Program Files\<comapany name>\Services folder to meet company standards
  4. Create a SQL database adding a login & db_datawriter roles to the account selected for the app pool
  5. Run SQL statement to build initial database

Creating a SQL database and Logins (4 & 5) seems possible through Custom Actions as I'll get to run my code at install time. But the web setup project by default only allows users to select from existing websites and app pools (1 & 2) and doesn't seem to allow me to customise this process except to add an image, this also means that the physical path for the selected website is used.

An option would be to create a suitable website & app pool prior to installation and remove it if it goes unused, then the user would simply need to select the website/app-pool I've created for them (not ideal but..) but there isn't a pre-installation step for me to attach such custom code to and I'm not sure how to interface with IIS reliably & programmatically.

Can anyone suggest the best way for me to approach creating the installer outlined above as I don't think web setup projects are fit for purpose at this stage, but would prefer not to have to waste a day learning WIX or NSIS.

Dead.Rabit
  • 1,965
  • 1
  • 28
  • 46
  • Please comment if you're gonna [-1] me so I get the chance for a come-back! (or perhaps learn something about my mis-use of this site) it's not a broad question, I've got specific requirements I'd like to achieve without changing technology (i.e: to WiX or NSIS as similar SO posts suggest). – Dead.Rabit Oct 04 '13 at 14:09
  • You have 5 questions and you say it's not broad? – Christopher Painter Oct 04 '13 at 15:21

2 Answers2

-1

1 & 3) Creating a new app pool isn't possible as there is no way to run custom code pre-installation in web setup projects, in my case it turned out to be acceptable for a user to create the website/app pool in IIS before installation. You can modify the Virtual Directory of the existing site through Microsoft.Web.Administration.dll (got the idea from here) if desired, by passing [TARGETSITE] to CustomActionData so you can find the Application object needed to modify the Virtual Directory.

2) This is achieved by referencing the Microsoft.Web.Administration.dll (got the idea from here) and using it to change application pool properties, you will need to pass the appPool name to the Custom action by adding /AppPool="[TARGETAPPPOOL]" to the CustomActionData for the CustomAction.

FYI - The available properties you may pass to CustomActionData are documented here but are incomplete (excluding [TARGETAPPPOOL] and [TARGETSITE] for example)

I used this code to modify the app pool:

Microsoft.Web.Administration.ServerManager serverManager = new ServerManager();
var appPoolName = base.Context.Parameters["AppPool"].ToString();
var appPool = serverManager.ApplicationPools.SingleOrDefault( pool => pool.Name == appPoolName );
appPool.ManagedRuntimeVersion = "v4.0";
appPool.ManagedPipelineMode = ManagedPipelineMode.Classic;
serverManager.CommitChanges();

4 - 5) Simply open a SQL Connection from a custom action and run the relevant SQL Scripts, you won't be able to add the true accounts ie: NT AUTHORITY\NETWORK SERVICE or NT AUTHORITY\ANONYMOUS, but may use the virtual user accounts IIS creates IIS APPPOOL\<app pool name>.

Community
  • 1
  • 1
Dead.Rabit
  • 1,965
  • 1
  • 28
  • 46
  • With such a horrible solution it should be obvious why Microsoft kicked this project type to the curb in VS2012. Using WiX or InstallShield you'd be able to do all of this without writing any custom actions or requiring your end user to do manual steps. – Christopher Painter Oct 04 '13 at 15:22
  • I'm sorry if I've offended you somehow, was very specific about not wanting to change to WiX, NSIS or InstallShield though as I'd loose too much time. Could you offer some guidance on how I could improve my answer/solution? – Dead.Rabit Oct 04 '13 at 15:33
-2

If you need to develop a sophisticated installer but don't want to spend even a day learning installer technologies then your best bet is probably to hire a consultant to do it for you.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • I am the consultant :S - I've got it sussed 1/2 day over budget, my biggest problem was finding the relevant parameters (for me AppPool name - [TARGETAPPPOOL]) to pass to the CustomActionData property so I could interact with it. Will post the real answer when I've cought up, but CustomActionData are very poorly documented, a list of parameters is at the link but it's an incomplete list so I had to find TARGETAPPPOOL through trial and error, and drop the requirement for adding new app pool/website for reasons I'll explain later http://msdn.microsoft.com/en-us/library/aa370905.aspx – Dead.Rabit Oct 04 '13 at 14:00
  • CusotmActionData isn't poorly documented, you've just never read about it. Deferred execution custom actions can run elevated so Microsoft created a security model to prevent security leaks. The CAD property is merely data being passed from the script generation to the script execution phase and it's up to you to decide how much data needs to be passed and how it should be structured. FWIW I could write and test this installer in a couple hours. But it took years to learn the skills to do it that quickly. – Christopher Painter Oct 04 '13 at 14:05