Web Deployment Tool (MS Deploy)
Specify an AppPool in my VS2010 deployment package
Last post Jul 25, 2011 12:21 AM by snixtor
Jul 15, 2011 07:28 AM|snixtor|LINK
I have a web application project in VS2010 and am using the "Build Deployment Package" facility to create an MSDeploy package file, very handy. I've found how to parameterise the application name, and parameterise web.config replacements, but the last requirement
I have has me running in circles...
I want to specify the name of the application pool to use, and if it doesn't exist, create it.
I see that if I configure my VS2010 project to use IIS, I can set it to "Include IIS settings as configured in IIS/IIS Express" and "Include application pool settings used by this Web project". So I see it's possible to include these settings in a deployment
package, but I do not want to rely on IIS environmental configuration to get the right deployment package because:
Web Deploy 2.0
Visual Studio 2010
Jul 15, 2011 12:33 PM|crossmonk|LINK
I've just been doing the same thing...although I've only gone as far as overriding the name e.g. I haven't gone as far as specifying the ASP.NET version or the pipeline mode...I probably should and I'll get round to it once I've solved my other issue
I've overidden the pool name by providing a <project>.wpp.targets file to override the settings in Microsoft.Web.Publishing.targets, it takes a bit of working out (documentation is non existant) and I may have been a bit clumsy but basically I've provided
my own "_Destination_IisServer_IisAppPoolName" property.
Now when someone imports my package they get an option to override the application pool name and the default value is set to what is in my <project>.wpp.targets file rather than the value on my dev box.
You also might want to check you have the latest version of Microsoft.Web.Publishing.targets otherwise you won't get some of the options (including the app pool name) in the GUI when importing the package etc.
If you work out how to specify the other settings please post back here.
Hope that helps :-)
Jul 15, 2011 11:29 PM|snixtor|LINK
crossmonk - Could you provide an extract from your wpp.targets showing how you've set that property? I'm still a bit of an MSBuild noob (combined with being an MSDeploy noob is making progress rather slow).
I can certainly see how to set a property, but I'm left wondering what target I need to latch onto, and also whether I need some other properties? It looks like somewhere around the GetProjectWebProperties target would be the spot, but in my case
I think the conditions for that particular target fail because I'm not using IIS from my VS project.
Jul 18, 2011 03:38 AM|snixtor|LINK
I'm wondering further if it's possible for me to hard-code values in my manifest.xml. I can sync app pool settings from IIS into a package, and see what sort of values I need in archive.xml, but it's rather difficult to customise the contents of archive.xml
using VS2010 "publish". It's relatively easy to get content into manifest.xml though.
Jul 18, 2011 09:12 AM|crossmonk|LINK
@Snixtor - it's disarmingly simple:
<_Destination_IisServer_IisAppPoolName>Your App Pool Name</_Destination_IisServer_IisAppPoolName>
The value is used to populate the "IIS Web Application Pool Name" parameter that you'll find in the auto-generated <package name>.SetParameters.xml in your package directory.
I really wish MS would provide a proper UI for setting this stuff, values like the app pool name are often going to be different on the build/package machine to the deployment target machine.
Reverse-engineering by dissecting verbose XML files is tedious and mistakes are very likely!
There's all kinds of useful looking parameters kicking around e.g. DestinationIisVersion I wonder what that does and how to set it? UI please...
Jul 22, 2011 12:53 AM|snixtor|LINK
I think your example there may be dependant on other package settings. I'm trying to create my packages without setting VS2010 to use IIS, which makes the package contents... a little bit different. But thanks for the input.
I've subsequently managed to do this by examining dump / sync packages from IIS and modifying archive.xml contents, but my real challenge now is to automatically produce a package from VS2010 that is compatible with IIS6 AND IIS7
AND includes AppPool configurations. What a mess...
Jul 22, 2011 10:42 AM|crossmonk|LINK
Yes, as with most of the settings you have to unpick the dependencies to determine which parameter(s) makes it into the final output, in my case for a package produced through VS2010 with "Include application pool settings..." ticked this was the appropriate
parameter to override.
Would you like to share how you solved the issue? e.g. which parameters were involved in your scenario?
Jul 25, 2011 12:21 AM|snixtor|LINK
I've chosen not to use "Include application pool settings" for a number of reasons.
I still haven't perfected what I'm doing here, but I've examined the MSDeploy package structure by creating an application in IIS7, along with an AppPool, and dumped details of it from the metakeys into packages, using commands like this:
msdeploy -verb:sync -source:metakey="lm/w3svc/1/root/MyApplication" -dest:package="AppDetails.zip"
msdeploy -verb:sync -source:metakey="lm/w3svc/AppPools/MyApplicationAppPool" -dest:package="AppPoolDetails.zip"
I've dumped metakeys to allow IIS6 compatibility. From these I've examined archive.xml to determine how the AppPool is created, and how it is assigned to the application itself.
With this knowledge I've added a <project_name>.wpp.targets file to my project, to get into the MSBuild web publishing pipeline. I've set the packaging settings to NOT package to a zip, so I can get easy access to archive.xml. In my wpp.targets file I have
a target set to AfterTargets="PackageUsingManifest" (I've found that target by examining the Microsoft.WebDeployment.targets file in program files\msbuild\microsoft\webdeployment\v10.0). In this target I've set a task like this:
This task uses an XML transform to modify the contents of my archive.xml (you'll note the archive2.xml output, since archive.xml is marked in use, as I said, I'm yet to perfect this). My archive.transform.xml looks like this, these are details I extracted
from my "AppPoolDetails.zip":
<metaKey xdt:Transform="Insert" path="/lm/w3svc/apppools/TestPool123" MSDeploy.path="2" setProperties="9027,1099,9026,1002,9028,9039,9041" MSDeploy.setProperties="1" MSDeploy.MSDeployLinkName="Child1" MSDeploy.MSDeployKeyAttributeName="path">
<metaProperty name="AppPoolState" propertyId="9027" attributes="Volatile" userType="1" dataType="DWord" value="4" MSDeploy.value="9" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="Win32Error" propertyId="1099" attributes="Volatile" userType="1" dataType="DWord" value="0" MSDeploy.value="9" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="AppPoolCommand" propertyId="9026" attributes="Volatile" userType="1" dataType="DWord" value="1" MSDeploy.value="9" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="KeyType" propertyId="1002" attributes="None" userType="1" dataType="String" value="IIsApplicationPool" MSDeploy.value="8" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="AppPoolAutoStart" propertyId="9028" attributes="Inherit" userType="1" dataType="DWord" value="1" MSDeploy.value="8" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="ManagedRuntimeVersion" propertyId="9039" attributes="Inherit" userType="1" dataType="String" value="v4.0" MSDeploy.value="8" MSDeploy.MSDeployKeyAttributeName="name" />
<metaProperty name="ManagedPipelineMode" propertyId="9041" attributes="Inherit" userType="1" dataType="DWord" value="0" MSDeploy.value="8" MSDeploy.MSDeployKeyAttributeName="name" />
This has allowed me to manually specify an AppPool to be created. A similar examination of the AppDetails.zip has helped me determine how the metakeys are laid out for an application, though I haven't yet configured the output from VS2010 to
work this way. I think that if you use the default createApp / iisApp tags in the archive.xml file, you can't readily assign the AppPool itself. I
may be able to get away with leaving those default tags as-is, but adding an appropriate AppPool assignment metakey entry (as found in AppDetails.zip).
All this!... just try try and create a single package from VS2010, that is IIS6 compatible, and allows me to create and assign an AppPool...